Page 1 of 1

SecureBridge - Loading a certificate at run-time

Posted: Sun 14 Mar 2021 20:53
by ertank
Hello,

I am using Delphi 10.3.3, UniDAC 8.3.2, SecureBridge 9.4.1, targetting FMX Android32 platform.

I would like to load client certificate and private key files at run-time into a TscMemoryStorage component. I know how to load private key at run-time. Unfortunately, I could not see how I should load certificate file at run-time.

I have a CRT extension certificate file with a content like below

Code: Select all

-----BEGIN CERTIFICATE-----
(Base64 encoded data)
-----END CERTIFICATE-----
There is no problem loading that certificate file in any storage component at design time. No error or anything.

I appreciate a small example for run-time certificate file loading.

Thanks & Regards,
Ertan

Re: SecureBridge - Loading a certificate at run-time

Posted: Tue 16 Mar 2021 05:38
by ViktorV
You can import certificates in run-time using the TScCertificate.ImportFrom method. For example:

Code: Select all

var
  Cert: TScCertificate;
...
  Cert := TScCertificate.Create(ScMemoryStorage.Certificates);
  Cert.Name := 'CertName'
  Cert.ImportFrom('ca-root.crt');
Note that, to use certificates in your application with the TScMemoryStorage component, you should load them each time you run the application, even if the certificates have been already loaded at design-time.