(PureBasic) Get Certificate's Public Key
Loads a certificate from PEM and gets the public key.
IncludeFile "CkPublicKey.pb"
IncludeFile "CkCert.pb"
Procedure ChilkatExample()
cert.i = CkCert::ckCreate()
If cert.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
strPem.s = "-----BEGIN CERTIFICATE----- ..."
success.i = CkCert::ckLoadPem(cert,strPem)
If success <> 1
Debug CkCert::ckLastErrorText(cert)
CkCert::ckDispose(cert)
ProcedureReturn
EndIf
pubKey.i = CkCert::ckExportPublicKey(cert)
If CkCert::ckLastMethodSuccess(cert) = 0
Debug CkCert::ckLastErrorText(cert)
CkCert::ckDispose(cert)
ProcedureReturn
EndIf
; You can now use the public key object however it is needed,
; and access its various properties and methods..
Debug CkPublicKey::ckGetXml(pubKey)
CkPublicKey::ckDispose(pubKey)
CkCert::ckDispose(cert)
ProcedureReturn
EndProcedure
|