(PureBasic) Get Certificate Public Key from PEM
Demonstrates how to load a PEM file containing a certificate and access the public key. Note: This example requires Chilkat v11.0.0 or greater.
IncludeFile "CkPublicKey.pb"
IncludeFile "CkCert.pb"
Procedure ChilkatExample()
success.i = 0
cert.i = CkCert::ckCreate()
If cert.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success = CkCert::ckLoadFromFile(cert,"qa_data/pem/my_cert.pem")
If success = 0
Debug CkCert::ckLastErrorText(cert)
CkCert::ckDispose(cert)
ProcedureReturn
EndIf
pubkey.i = CkPublicKey::ckCreate()
If pubkey.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkCert::ckGetPublicKey(cert,pubkey)
; Examine the public key as XML..
Debug CkPublicKey::ckGetXml(pubkey)
CkCert::ckDispose(cert)
CkPublicKey::ckDispose(pubkey)
ProcedureReturn
EndProcedure
|