Xbase++
Xbase++
Load Certificate from .cer and Private Key from .pem
See more Certificates Examples
Load a certificate from a .cer and its associated private key from a .pem.Chilkat Xbase++ Downloads
LOCAL nSuccess
LOCAL oCert
LOCAL oSbPem
nSuccess := 0
oCert := CreateObject("Chilkat.Cert")
nSuccess := oCert:LoadFromFile("C:/certs_and_keys/Certificate.cer")
IF (nSuccess == 0)
? oCert:LastErrorText
oCert:destroy()
RETURN
ENDIF
oSbPem := CreateObject("Chilkat.StringBuilder")
nSuccess := oSbPem:LoadFile("C:/certs_and_keys/PrivateKey.pem", "utf-8")
IF (nSuccess == 0)
? "Failed to load private key PEM"
oCert:destroy()
oSbPem:destroy()
RETURN
ENDIF
nSuccess := oCert:SetPrivateKeyPem(oSbPem:GetAsString())
IF (nSuccess == 0)
? oCert:LastErrorText
oCert:destroy()
oSbPem:destroy()
RETURN
ENDIF
? "The certificate and associated private key are now loaded and ready for signing."
oCert:destroy()
oSbPem:destroy()