PureBasic
PureBasic
Get Public Key from Certificate PEM
See more Certificates Examples
Loads a certificate from a PEM file and gets the cert's public key.Chilkat PureBasic Downloads
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/certs/someCert.pem")
If success = 0
Debug CkCert::ckLastErrorText(cert)
CkCert::ckDispose(cert)
ProcedureReturn
EndIf
; Get the certificate's public key:
pubkey.i = CkPublicKey::ckCreate()
If pubkey.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkCert::ckGetPublicKey(cert,pubkey)
Debug CkPublicKey::ckGetPem(pubkey,0)
; OK.. we have the public key which can be used in other Chilkat classes/methods...
CkCert::ckDispose(cert)
CkPublicKey::ckDispose(pubkey)
ProcedureReturn
EndProcedure