Azure Key Vault: Import a PFX with Cert.UploadToCloud
See more Azure Key Vault Examples
Requires Chilkat 11.6.0 or later. Keep qa_data/azure/keyvault.json and token/PFX files private, outside web content and source control, with access restricted to the application identity. Use placeholders replaced by your configuration, never commit credentials. Create output directories before running file-writing examples. These examples target Azure public-cloud vaults, not Managed HSM or sovereign-cloud endpoints.
Uses Chilkat's cloud convenience integration with client_id, client_secret, tenant_id (directory GUID), vault_name, and cert_name in private configuration. The installed Chilkat library manages authentication and service API versions for this helper; this example does not select a REST api-version. Use the explicit Http examples when that control is required. Keep the runtime current and inspect diagnostics privately.
Set cert_name and string pfx_password; load a PFX containing the leaf certificate and its private key from qa_data/pfx/myCertAndKey.pfx. The sample accepts RSA 2048/3072/4096 and NIST EC P-256/P-384/P-521. Import creates a new version if the name already exists. Keep a protected backup and reconcile uncertain failures before retrying. Requires certificates/import. Keep PFX material, request bodies, and diagnostics private; only resource identifiers are printed. The returned leaf certificate is checked against the source.
This shortcut uses the helper's import policy. It does not set the explicit nonexportable policy shown in the low-level Http example; inspect the resulting policy and use the REST example when exportability or key reuse must be controlled. Tags are omitted so certificate identity details are not copied into metadata.
Chilkat Delphi DLL Downloads
var
success: Boolean;
stringCompare: HCkStringBuilder;
config: HCkJsonObject;
stringMatch1: Boolean;
validate1: HCkStringBuilder;
alphabet1: HCkStringBuilder;
charIndex1: Integer;
vaultName: HCkStringBuilder;
letters: HCkStringBuilder;
origin: HCkStringBuilder;
stringMatch2: Boolean;
validate2: HCkStringBuilder;
alphabet2: HCkStringBuilder;
charIndex2: Integer;
stringMatch3: Boolean;
stringMatch4: Boolean;
stringMatch5: Boolean;
validate4: HCkStringBuilder;
alphabet4: HCkStringBuilder;
charIndex4: Integer;
cert: HCkCert;
privateKey: HCkPrivateKey;
publicKey: HCkPublicKey;
publicJwk: PWideChar;
keyInfo: HCkJsonObject;
supported: Boolean;
stringMatch6: Boolean;
stringMatch7: Boolean;
stringMatch8: Boolean;
stringMatch9: Boolean;
stringMatch10: Boolean;
options: HCkJsonObject;
result: HCkJsonObject;
certificateBase: HCkStringBuilder;
bundlePrefix: HCkStringBuilder;
stringMatch11: Boolean;
stringMatch12: Boolean;
stringMatch13: Boolean;
certificateVersionId: HCkStringBuilder;
certificateVersion: PWideChar;
validate7: HCkStringBuilder;
alphabet7: HCkStringBuilder;
charIndex7: Integer;
keyPrefix: HCkStringBuilder;
keyTailId: HCkStringBuilder;
keyTail: PWideChar;
keyTailParts: HCkStringBuilder;
keyTailName: PWideChar;
keyTailVersion: PWideChar;
validate8: HCkStringBuilder;
alphabet8: HCkStringBuilder;
charIndex8: Integer;
validate9: HCkStringBuilder;
alphabet9: HCkStringBuilder;
charIndex9: Integer;
keyTailCanonical: HCkStringBuilder;
stringMatch14: Boolean;
certificateId: PWideChar;
keyId: PWideChar;
remoteCert: HCkCert;
sourceDer: PWideChar;
importedDer: PWideChar;
stringMatch15: Boolean;
begin
success := False;
stringCompare := CkStringBuilder_Create();
// Assumes Chilkat is unlocked. See Global Unlock Sample.
// Keep this configuration private, outside public web content and source control.
config := CkJsonObject_Create();
CkJsonObject_putStrict(config,True);
success := CkJsonObject_LoadFile(config,'qa_data/azure/keyvault.json');
if (success <> True) then
begin
Memo1.Lines.Add('Could not load private Key Vault configuration.');
Exit;
end;
CkStringBuilder_SetString(stringCompare,CkJsonObject__stringOf(config,'vault_name'));
stringMatch1 := CkStringBuilder_ContentsEqual(stringCompare,'',True);
if ((CkJsonObject_JsonTypeOf(config,'vault_name') <> 1) or (stringMatch1 = True)) then
begin
Memo1.Lines.Add('Missing or invalid vault_name.');
Exit;
end;
validate1 := CkStringBuilder_Create();
alphabet1 := CkStringBuilder_Create();
success := CkStringBuilder_Append(validate1,CkJsonObject__stringOf(config,'vault_name'));
if (success <> True) then
begin
Memo1.Lines.Add('Could not validate vault_name.');
Exit;
end;
success := CkStringBuilder_Append(alphabet1,'abcdefghijklmnopqrstuvwxyz0123456789-');
if (success <> True) then
begin
Memo1.Lines.Add('Could not initialize validation.');
Exit;
end;
if ((CkStringBuilder_getLength(validate1) < 3) or (CkStringBuilder_getLength(validate1) > 24)) then
begin
Memo1.Lines.Add('Invalid vault_name length.');
Exit;
end;
charIndex1 := 0;
while (charIndex1 < CkStringBuilder_getLength(validate1)) do
begin
if (CkStringBuilder_Contains(alphabet1,CkStringBuilder__getRange(validate1,charIndex1,1,False),True) <> True) then
begin
Memo1.Lines.Add('Invalid character in vault_name.');
Exit;
end;
charIndex1 := charIndex1 + 1;
end;
vaultName := CkStringBuilder_Create();
CkStringBuilder_Append(vaultName,CkJsonObject__stringOf(config,'vault_name'));
letters := CkStringBuilder_Create();
CkStringBuilder_Append(letters,'abcdefghijklmnopqrstuvwxyz');
if ((CkStringBuilder_Contains(letters,CkStringBuilder__getRange(vaultName,0,1,False),True) <> True) or (CkStringBuilder_EndsWith(vaultName,'-',True) = True) or (CkStringBuilder_Contains(vaultName,'--',True) = True)) then
begin
Memo1.Lines.Add('Invalid vault_name.');
Exit;
end;
origin := CkStringBuilder_Create();
success := CkStringBuilder_Append(origin,'https://');
if (success <> True) then
begin
Memo1.Lines.Add('Could not construct URL or identifier.');
Exit;
end;
success := CkStringBuilder_Append(origin,CkJsonObject__stringOf(config,'vault_name'));
if (success <> True) then
begin
Memo1.Lines.Add('Could not construct URL or identifier.');
Exit;
end;
success := CkStringBuilder_Append(origin,'.vault.azure.net');
if (success <> True) then
begin
Memo1.Lines.Add('Could not construct URL or identifier.');
Exit;
end;
CkStringBuilder_SetString(stringCompare,CkJsonObject__stringOf(config,'cert_name'));
stringMatch2 := CkStringBuilder_ContentsEqual(stringCompare,'',True);
if ((CkJsonObject_JsonTypeOf(config,'cert_name') <> 1) or (stringMatch2 = True)) then
begin
Memo1.Lines.Add('Missing or invalid cert_name.');
Exit;
end;
validate2 := CkStringBuilder_Create();
alphabet2 := CkStringBuilder_Create();
success := CkStringBuilder_Append(validate2,CkJsonObject__stringOf(config,'cert_name'));
if (success <> True) then
begin
Memo1.Lines.Add('Could not validate cert_name.');
Exit;
end;
success := CkStringBuilder_Append(alphabet2,'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-');
if (success <> True) then
begin
Memo1.Lines.Add('Could not initialize validation.');
Exit;
end;
if ((CkStringBuilder_getLength(validate2) < 1) or (CkStringBuilder_getLength(validate2) > 127)) then
begin
Memo1.Lines.Add('Invalid cert_name length.');
Exit;
end;
charIndex2 := 0;
while (charIndex2 < CkStringBuilder_getLength(validate2)) do
begin
if (CkStringBuilder_Contains(alphabet2,CkStringBuilder__getRange(validate2,charIndex2,1,False),True) <> True) then
begin
Memo1.Lines.Add('Invalid character in cert_name.');
Exit;
end;
charIndex2 := charIndex2 + 1;
end;
CkStringBuilder_SetString(stringCompare,CkJsonObject__stringOf(config,'client_id'));
stringMatch3 := CkStringBuilder_ContentsEqual(stringCompare,'',True);
if ((CkJsonObject_JsonTypeOf(config,'client_id') <> 1) or (stringMatch3 = True)) then
begin
Memo1.Lines.Add('Missing or invalid client_id.');
Exit;
end;
CkStringBuilder_SetString(stringCompare,CkJsonObject__stringOf(config,'client_secret'));
stringMatch4 := CkStringBuilder_ContentsEqual(stringCompare,'',True);
if ((CkJsonObject_JsonTypeOf(config,'client_secret') <> 1) or (stringMatch4 = True)) then
begin
Memo1.Lines.Add('Missing or invalid client_secret.');
Exit;
end;
CkStringBuilder_SetString(stringCompare,CkJsonObject__stringOf(config,'tenant_id'));
stringMatch5 := CkStringBuilder_ContentsEqual(stringCompare,'',True);
if ((CkJsonObject_JsonTypeOf(config,'tenant_id') <> 1) or (stringMatch5 = True)) then
begin
Memo1.Lines.Add('Missing or invalid tenant_id.');
Exit;
end;
validate4 := CkStringBuilder_Create();
alphabet4 := CkStringBuilder_Create();
success := CkStringBuilder_Append(validate4,CkJsonObject__stringOf(config,'tenant_id'));
if (success <> True) then
begin
Memo1.Lines.Add('Could not validate tenant GUID.');
Exit;
end;
success := CkStringBuilder_Append(alphabet4,'0123456789abcdefABCDEF-');
if (success <> True) then
begin
Memo1.Lines.Add('Could not initialize validation.');
Exit;
end;
if ((CkStringBuilder_getLength(validate4) < 36) or (CkStringBuilder_getLength(validate4) > 36)) then
begin
Memo1.Lines.Add('Invalid tenant GUID length.');
Exit;
end;
charIndex4 := 0;
while (charIndex4 < CkStringBuilder_getLength(validate4)) do
begin
if (CkStringBuilder_Contains(alphabet4,CkStringBuilder__getRange(validate4,charIndex4,1,False),True) <> True) then
begin
Memo1.Lines.Add('Invalid character in tenant GUID.');
Exit;
end;
charIndex4 := charIndex4 + 1;
end;
if (CkJsonObject_JsonTypeOf(config,'pfx_password') <> 1) then
begin
Memo1.Lines.Add('Missing pfx_password string; empty is allowed for an unprotected PFX.');
Exit;
end;
cert := CkCert_Create();
success := CkCert_LoadPfxFile(cert,'qa_data/pfx/myCertAndKey.pfx',CkJsonObject__stringOf(config,'pfx_password'));
if (success <> True) then
begin
Memo1.Lines.Add('Could not load PFX; inspect diagnostics privately.');
Exit;
end;
privateKey := CkPrivateKey_Create();
success := CkCert_GetPrivateKey(cert,privateKey);
if (success <> True) then
begin
Memo1.Lines.Add('PFX must contain a usable private key.');
Exit;
end;
// Inspect only the PUBLIC JWK. Never print or export a private JWK for key inspection.
publicKey := CkPublicKey_Create();
success := CkPrivateKey_ToPublicKey(privateKey,publicKey);
if (success <> True) then
begin
Memo1.Lines.Add('Could not get the public key.');
Exit;
end;
publicJwk := CkPublicKey__getJwk(publicKey);
if (CkPublicKey_getLastMethodSuccess(publicKey) <> True) then
begin
Memo1.Lines.Add('Could not inspect the public key.');
Exit;
end;
keyInfo := CkJsonObject_Create();
CkJsonObject_putStrict(keyInfo,True);
success := CkJsonObject_Load(keyInfo,publicJwk);
if (success <> True) then
begin
Memo1.Lines.Add('Invalid public JWK.');
Exit;
end;
supported := False;
CkStringBuilder_SetString(stringCompare,CkJsonObject__stringOf(keyInfo,'kty'));
stringMatch6 := CkStringBuilder_ContentsEqual(stringCompare,'RSA',True);
if (stringMatch6 = True) then
begin
supported := (CkPrivateKey_getBitLength(privateKey) = 2048) or (CkPrivateKey_getBitLength(privateKey) = 3072) or (CkPrivateKey_getBitLength(privateKey) = 4096);
end;
CkStringBuilder_SetString(stringCompare,CkJsonObject__stringOf(keyInfo,'kty'));
stringMatch7 := CkStringBuilder_ContentsEqual(stringCompare,'EC',True);
if (stringMatch7 = True) then
begin
CkStringBuilder_SetString(stringCompare,CkJsonObject__stringOf(keyInfo,'crv'));
stringMatch8 := CkStringBuilder_ContentsEqual(stringCompare,'P-256',True);
CkStringBuilder_SetString(stringCompare,CkJsonObject__stringOf(keyInfo,'crv'));
stringMatch9 := CkStringBuilder_ContentsEqual(stringCompare,'P-384',True);
CkStringBuilder_SetString(stringCompare,CkJsonObject__stringOf(keyInfo,'crv'));
stringMatch10 := CkStringBuilder_ContentsEqual(stringCompare,'P-521',True);
if ((stringMatch8 = True) or (stringMatch9 = True) or (stringMatch10 = True)) then
begin
supported := True;
end;
end;
if (supported <> True) then
begin
Memo1.Lines.Add('This example supports RSA 2048/3072/4096 and NIST P-256/P-384/P-521.');
Exit;
end;
options := CkJsonObject_Create();
success := CkJsonObject_UpdateString(options,'service','azure-keyvault');
if (success <> True) then
begin
Memo1.Lines.Add('Could not set service.');
Exit;
end;
success := CkJsonObject_UpdateString(options,'auth.client_id',CkJsonObject__stringOf(config,'client_id'));
if (success <> True) then
begin
Memo1.Lines.Add('Could not set auth.client_id.');
Exit;
end;
success := CkJsonObject_UpdateString(options,'auth.client_secret',CkJsonObject__stringOf(config,'client_secret'));
if (success <> True) then
begin
Memo1.Lines.Add('Could not set auth.client_secret.');
Exit;
end;
success := CkJsonObject_UpdateString(options,'auth.tenant_id',CkJsonObject__stringOf(config,'tenant_id'));
if (success <> True) then
begin
Memo1.Lines.Add('Could not set auth.tenant_id.');
Exit;
end;
success := CkJsonObject_UpdateString(options,'vault_name',CkJsonObject__stringOf(config,'vault_name'));
if (success <> True) then
begin
Memo1.Lines.Add('Could not set vault_name.');
Exit;
end;
success := CkJsonObject_UpdateString(options,'cert_name',CkJsonObject__stringOf(config,'cert_name'));
if (success <> True) then
begin
Memo1.Lines.Add('Could not set cert_name.');
Exit;
end;
result := CkJsonObject_Create();
CkJsonObject_putStrict(result,True);
// UploadToCloud uses azure-keyvault; SetCloudSigner uses azure_keyvault.
success := CkCert_UploadToCloud(cert,options,result);
if (success <> True) then
begin
Memo1.Lines.Add('Import failed or its outcome is uncertain. Check the vault before retrying.');
Exit;
end;
certificateBase := CkStringBuilder_Create();
success := CkStringBuilder_Append(certificateBase,CkStringBuilder__getAsString(origin));
if (success <> True) then
begin
Memo1.Lines.Add('Could not construct URL or identifier.');
Exit;
end;
success := CkStringBuilder_Append(certificateBase,'/certificates/');
if (success <> True) then
begin
Memo1.Lines.Add('Could not construct URL or identifier.');
Exit;
end;
success := CkStringBuilder_Append(certificateBase,CkJsonObject__stringOf(config,'cert_name'));
if (success <> True) then
begin
Memo1.Lines.Add('Could not construct URL or identifier.');
Exit;
end;
bundlePrefix := CkStringBuilder_Create();
success := CkStringBuilder_Append(bundlePrefix,CkStringBuilder__getAsString(certificateBase));
if (success <> True) then
begin
Memo1.Lines.Add('Could not construct URL or identifier.');
Exit;
end;
success := CkStringBuilder_Append(bundlePrefix,'/');
if (success <> True) then
begin
Memo1.Lines.Add('Could not construct URL or identifier.');
Exit;
end;
CkStringBuilder_SetString(stringCompare,CkJsonObject__stringOf(result,'id'));
stringMatch11 := CkStringBuilder_ContentsEqual(stringCompare,'',True);
if ((CkJsonObject_JsonTypeOf(result,'id') <> 1) or (stringMatch11 = True)) then
begin
Memo1.Lines.Add('Missing or invalid id.');
Exit;
end;
CkStringBuilder_SetString(stringCompare,CkJsonObject__stringOf(result,'kid'));
stringMatch12 := CkStringBuilder_ContentsEqual(stringCompare,'',True);
if ((CkJsonObject_JsonTypeOf(result,'kid') <> 1) or (stringMatch12 = True)) then
begin
Memo1.Lines.Add('Missing or invalid kid.');
Exit;
end;
CkStringBuilder_SetString(stringCompare,CkJsonObject__stringOf(result,'cer'));
stringMatch13 := CkStringBuilder_ContentsEqual(stringCompare,'',True);
if ((CkJsonObject_JsonTypeOf(result,'cer') <> 1) or (stringMatch13 = True)) then
begin
Memo1.Lines.Add('Missing or invalid cer.');
Exit;
end;
certificateVersionId := CkStringBuilder_Create();
success := CkStringBuilder_Append(certificateVersionId,CkJsonObject__stringOf(result,'id'));
if (success <> True) then
begin
Memo1.Lines.Add('Could not construct URL or identifier.');
Exit;
end;
if (CkStringBuilder_StartsWith(certificateVersionId,CkStringBuilder__getAsString(bundlePrefix),True) <> True) then
begin
Memo1.Lines.Add('Returned identifier is outside the expected vault/resource.');
Exit;
end;
certificateVersion := CkStringBuilder__getRange(certificateVersionId,CkStringBuilder_getLength(bundlePrefix),CkStringBuilder_getLength(certificateVersionId) - CkStringBuilder_getLength(bundlePrefix),False);
validate7 := CkStringBuilder_Create();
alphabet7 := CkStringBuilder_Create();
success := CkStringBuilder_Append(validate7,certificateVersion);
if (success <> True) then
begin
Memo1.Lines.Add('Could not validate resource identifier.');
Exit;
end;
success := CkStringBuilder_Append(alphabet7,'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-');
if (success <> True) then
begin
Memo1.Lines.Add('Could not initialize validation.');
Exit;
end;
if ((CkStringBuilder_getLength(validate7) < 1) or (CkStringBuilder_getLength(validate7) > 127)) then
begin
Memo1.Lines.Add('Invalid resource identifier length.');
Exit;
end;
charIndex7 := 0;
while (charIndex7 < CkStringBuilder_getLength(validate7)) do
begin
if (CkStringBuilder_Contains(alphabet7,CkStringBuilder__getRange(validate7,charIndex7,1,False),True) <> True) then
begin
Memo1.Lines.Add('Invalid character in resource identifier.');
Exit;
end;
charIndex7 := charIndex7 + 1;
end;
keyPrefix := CkStringBuilder_Create();
success := CkStringBuilder_Append(keyPrefix,CkStringBuilder__getAsString(origin));
if (success <> True) then
begin
Memo1.Lines.Add('Could not construct URL or identifier.');
Exit;
end;
success := CkStringBuilder_Append(keyPrefix,'/keys/');
if (success <> True) then
begin
Memo1.Lines.Add('Could not construct URL or identifier.');
Exit;
end;
keyTailId := CkStringBuilder_Create();
success := CkStringBuilder_Append(keyTailId,CkJsonObject__stringOf(result,'kid'));
if (success <> True) then
begin
Memo1.Lines.Add('Could not construct URL or identifier.');
Exit;
end;
if (CkStringBuilder_StartsWith(keyTailId,CkStringBuilder__getAsString(keyPrefix),True) <> True) then
begin
Memo1.Lines.Add('Returned identifier is outside the expected vault/resource.');
Exit;
end;
keyTail := CkStringBuilder__getRange(keyTailId,CkStringBuilder_getLength(keyPrefix),CkStringBuilder_getLength(keyTailId) - CkStringBuilder_getLength(keyPrefix),False);
keyTailParts := CkStringBuilder_Create();
success := CkStringBuilder_Append(keyTailParts,keyTail);
if (success <> True) then
begin
Memo1.Lines.Add('Could not construct URL or identifier.');
Exit;
end;
keyTailName := CkStringBuilder__getBefore(keyTailParts,'/',False);
keyTailVersion := CkStringBuilder__getAfterFinal(keyTailParts,'/',False);
validate8 := CkStringBuilder_Create();
alphabet8 := CkStringBuilder_Create();
success := CkStringBuilder_Append(validate8,keyTailName);
if (success <> True) then
begin
Memo1.Lines.Add('Could not validate resource name.');
Exit;
end;
success := CkStringBuilder_Append(alphabet8,'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-');
if (success <> True) then
begin
Memo1.Lines.Add('Could not initialize validation.');
Exit;
end;
if ((CkStringBuilder_getLength(validate8) < 1) or (CkStringBuilder_getLength(validate8) > 127)) then
begin
Memo1.Lines.Add('Invalid resource name length.');
Exit;
end;
charIndex8 := 0;
while (charIndex8 < CkStringBuilder_getLength(validate8)) do
begin
if (CkStringBuilder_Contains(alphabet8,CkStringBuilder__getRange(validate8,charIndex8,1,False),True) <> True) then
begin
Memo1.Lines.Add('Invalid character in resource name.');
Exit;
end;
charIndex8 := charIndex8 + 1;
end;
validate9 := CkStringBuilder_Create();
alphabet9 := CkStringBuilder_Create();
success := CkStringBuilder_Append(validate9,keyTailVersion);
if (success <> True) then
begin
Memo1.Lines.Add('Could not validate resource version.');
Exit;
end;
success := CkStringBuilder_Append(alphabet9,'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-');
if (success <> True) then
begin
Memo1.Lines.Add('Could not initialize validation.');
Exit;
end;
if ((CkStringBuilder_getLength(validate9) < 1) or (CkStringBuilder_getLength(validate9) > 127)) then
begin
Memo1.Lines.Add('Invalid resource version length.');
Exit;
end;
charIndex9 := 0;
while (charIndex9 < CkStringBuilder_getLength(validate9)) do
begin
if (CkStringBuilder_Contains(alphabet9,CkStringBuilder__getRange(validate9,charIndex9,1,False),True) <> True) then
begin
Memo1.Lines.Add('Invalid character in resource version.');
Exit;
end;
charIndex9 := charIndex9 + 1;
end;
keyTailCanonical := CkStringBuilder_Create();
success := CkStringBuilder_Append(keyTailCanonical,keyTailName);
if (success <> True) then
begin
Memo1.Lines.Add('Could not construct URL or identifier.');
Exit;
end;
success := CkStringBuilder_Append(keyTailCanonical,'/');
if (success <> True) then
begin
Memo1.Lines.Add('Could not construct URL or identifier.');
Exit;
end;
success := CkStringBuilder_Append(keyTailCanonical,keyTailVersion);
if (success <> True) then
begin
Memo1.Lines.Add('Could not construct URL or identifier.');
Exit;
end;
CkStringBuilder_SetString(stringCompare,keyTail);
stringMatch14 := CkStringBuilder_ContentsEqual(stringCompare,CkStringBuilder__getAsString(keyTailCanonical),True);
if (stringMatch14 <> True) then
begin
Memo1.Lines.Add('Expected a versioned resource identifier.');
Exit;
end;
certificateId := CkJsonObject__stringOf(result,'id');
keyId := CkJsonObject__stringOf(result,'kid');
remoteCert := CkCert_Create();
success := CkCert_LoadFromBase64(remoteCert,CkJsonObject__stringOf(result,'cer'));
if (success <> True) then
begin
Memo1.Lines.Add('Could not load the returned public certificate.');
Exit;
end;
sourceDer := CkCert__getEncoded(cert);
if (CkCert_getLastMethodSuccess(cert) <> True) then
begin
Memo1.Lines.Add('Could not encode source certificate.');
Exit;
end;
importedDer := CkCert__getEncoded(remoteCert);
if (CkCert_getLastMethodSuccess(remoteCert) <> True) then
begin
Memo1.Lines.Add('Could not encode imported certificate.');
Exit;
end;
CkStringBuilder_SetString(stringCompare,sourceDer);
stringMatch15 := CkStringBuilder_ContentsEqual(stringCompare,importedDer,True);
if (stringMatch15 <> True) then
begin
Memo1.Lines.Add('Imported certificate does not match the PFX leaf certificate.');
Exit;
end;
Memo1.Lines.Add('Imported certificate ID: ' + certificateId);
Memo1.Lines.Add('Backing key ID: ' + keyId);
CkStringBuilder_Dispose(stringCompare);
CkJsonObject_Dispose(config);
CkStringBuilder_Dispose(validate1);
CkStringBuilder_Dispose(alphabet1);
CkStringBuilder_Dispose(vaultName);
CkStringBuilder_Dispose(letters);
CkStringBuilder_Dispose(origin);
CkStringBuilder_Dispose(validate2);
CkStringBuilder_Dispose(alphabet2);
CkStringBuilder_Dispose(validate4);
CkStringBuilder_Dispose(alphabet4);
CkCert_Dispose(cert);
CkPrivateKey_Dispose(privateKey);
CkPublicKey_Dispose(publicKey);
CkJsonObject_Dispose(keyInfo);
CkJsonObject_Dispose(options);
CkJsonObject_Dispose(result);
CkStringBuilder_Dispose(certificateBase);
CkStringBuilder_Dispose(bundlePrefix);
CkStringBuilder_Dispose(certificateVersionId);
CkStringBuilder_Dispose(validate7);
CkStringBuilder_Dispose(alphabet7);
CkStringBuilder_Dispose(keyPrefix);
CkStringBuilder_Dispose(keyTailId);
CkStringBuilder_Dispose(keyTailParts);
CkStringBuilder_Dispose(validate8);
CkStringBuilder_Dispose(alphabet8);
CkStringBuilder_Dispose(validate9);
CkStringBuilder_Dispose(alphabet9);
CkStringBuilder_Dispose(keyTailCanonical);
CkCert_Dispose(remoteCert);