Hi, I am trying to replace my CAPICOM handling of certificates with SecureBridge. Seemed promising, but now i tried importing a .p12 file with code like this:
var
crt: TScCertificate;
crt := TScCertificate.Create(<TScCryptoAPIStorage>.Certificates);
crt.ImportFrom(<FileName>, <Pwd>);
This doesn't work as the import doesn't seem to find anything in the file, especially not the CertName.
However, after importing the cert from e g InternetExplorer, I can handle it with help of SecureBridge: list, use, delete...
Am I missing something, or is it just impossible to open .p12 certs? Is there a way to circumvent the problem?
/Anders
Importing .p12 files
Re: Importing .p12 files
Support obviously died, went on vaccation or something, no answer to anything during the whole of June...
/Anders
/Anders
Re: Importing .p12 files
Please give more detailed description of the problem. Is there an exception raised? If yes, specify the exact exception message.
Re: Importing .p12 files
I thought maybe .p12 was not able to be opened, as that filetype is not in the list of values?
The error I get is:
"<my project> raised exception class EScError with message 'Certificate name missing'."
This is what I see:
* ScBridge.pas 6350: After setting value to CertData, the string is totally unreadable, thus the 2 following searches for 'CERTIFICATE' and 'X509 CERTIFICATE' fail => CertStr is empty.
* ScBridge.pas 6367: the call to BaseStorage.ImportCert seems to work => ce has a value.
* ScBridge.pas 6407: CertName is empty => no CertificateList.Storage.Save(Self)!
I see now, that the error really shows up on a line I didn't show you. This is my - fuller - code:
var
crt: TScCertificate;
begin
crt := TScCertificate.Create(CryptoStorage.Certificates);
crt.ImportFrom(AFileName, APwd);
CryptoStorage.Certificates.Add(crt); // << This is where I get the error!
end;
I thought maybe importing did the whole thing, but removing third line and reloading the repository doesn't seem to help.
Hopefully this was clearer?
/Anders
The error I get is:
"<my project> raised exception class EScError with message 'Certificate name missing'."
This is what I see:
* ScBridge.pas 6350: After setting value to CertData, the string is totally unreadable, thus the 2 following searches for 'CERTIFICATE' and 'X509 CERTIFICATE' fail => CertStr is empty.
* ScBridge.pas 6367: the call to BaseStorage.ImportCert seems to work => ce has a value.
* ScBridge.pas 6407: CertName is empty => no CertificateList.Storage.Save(Self)!
I see now, that the error really shows up on a line I didn't show you. This is my - fuller - code:
var
crt: TScCertificate;
begin
crt := TScCertificate.Create(CryptoStorage.Certificates);
crt.ImportFrom(AFileName, APwd);
CryptoStorage.Certificates.Add(crt); // << This is where I get the error!
end;
I thought maybe importing did the whole thing, but removing third line and reloading the repository doesn't seem to help.
Hopefully this was clearer?

/Anders
Re: Importing .p12 files
You should set the certificate name before saving the certificate into the certificate storage. You can use the following code:
Code: Select all
crt := TScCertificate.Create(CryptoStorage.Certificates);
crt.ImportFrom(AFileName, APwd);
crt.CertName := 'my_cert';
CryptoStorage.Certificates.Add(crt);
Re: Importing .p12 files
Thanks, that seems to work fine 
... with the exception that the last line (CryptoStorage.Certificates.Add(crt);
) should be removed. Setting the CertName already adds the cert to the list, and the Add just causes a "duplicate name" error!
/Anders

... with the exception that the last line (CryptoStorage.Certificates.Add(crt);
) should be removed. Setting the CertName already adds the cert to the list, and the Add just causes a "duplicate name" error!
/Anders