SecureBridge - Loading a certificate at run-time

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
ertank
Posts: 172
Joined: Wed 13 Jan 2016 16:00

SecureBridge - Loading a certificate at run-time

Post by ertank » Sun 14 Mar 2021 20:53

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

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: SecureBridge - Loading a certificate at run-time

Post by ViktorV » Tue 16 Mar 2021 05:38

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.

Post Reply