1. Importing a private key and a public-key certificate, assigning the imported key to the selected certificate, installing the resulting private-key certificate to the personal certificate storage.
clCertificateStore1.Open('MY');
clCertificateStore1.CSP := MS_ENH_RSA_AES_PROV;
clCertificateStore1.ProviderType := PROV_RSA_AES;
clCertificateStore1.ImportKey('private-key-name-1234567890', 'privatekey.pem');
clCertificateStore1.ImportFromCER('cert.cer');
cert := clCertificateStore1.CertificateByThumbprint('3214a0.........');
cert.SetPrivateKey('private-key-name-1234567890', clCertificateStore1.CSP, clCertificateStore1.ProviderType, ktKeyExchange);
clCertificateStore1.Install(cert);
2. Exporting the private key from the selected certificate and saving the key to a file.
clCertificateStore1.Open('MY');
clCertificateStore1.CSP := MS_ENH_RSA_AES_PROV;
clCertificateStore1.ProviderType := PROV_RSA_AES;
cert := clCertificateStore1.CertificateByThumbprint('3214a0.........');
clCertificateStore1.ExportKey(cert.PrivateKey, 'privatekey.pem');
Article ID: 104, Created: May 14, 2018 at 7:32 PM, Modified: May 15, 2018 at 2:10 PM