(Lianja) Load Certificate from .cer and Private Key from .pem
Load a certificate from a .cer and its associated private key from a .pem.
loCert = createobject("CkCert")
llSuccess = loCert.LoadFromFile("C:/certs_and_keys/Certificate.cer")
if (llSuccess = .F.) then
? loCert.LastErrorText
release loCert
return
endif
loSbPem = createobject("CkStringBuilder")
llSuccess = loSbPem.LoadFile("C:/certs_and_keys/PrivateKey.pem","utf-8")
if (llSuccess = .F.) then
? "Failed to load private key PEM"
release loCert
release loSbPem
return
endif
llSuccess = loCert.SetPrivateKeyPem(loSbPem.GetAsString())
if (llSuccess = .F.) then
? loCert.LastErrorText
release loCert
release loSbPem
return
endif
? "The certificate and associated private key are now loaded and ready for signing."
release loCert
release loSbPem
|