Sample code for 30+ languages & platforms
Xbase++ Requires Chilkat v11.0.0+

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 Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oCert
LOCAL oPubkey

nSuccess := 0

oCert := CreateObject("Chilkat.Cert")

nSuccess := oCert:LoadFromFile("qa_data/certs/someCert.pem")
IF (nSuccess == 0)
    ? oCert:LastErrorText
    oCert:destroy()
    RETURN
ENDIF

//  Get the certificate's public key:
oPubkey := CreateObject("Chilkat.PublicKey")
oCert:GetPublicKey(oPubkey)

? oPubkey:GetPem(0)

//  OK.. we have the public key which can be used in other Chilkat classes/methods...

oCert:destroy()
oPubkey:destroy()