Sample code for 30+ languages & platforms
Go

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 Go Downloads

Go
    success := false

    cert := chilkat.NewCert()

    success = cert.LoadFromFile("qa_data/certs/someCert.pem")
    if success == false {
        fmt.Println(cert.LastErrorText())
        cert.DisposeCert()
        return
    }

    // Get the certificate's public key:
    pubkey := chilkat.NewPublicKey()
    cert.GetPublicKey(pubkey)

    fmt.Println(*pubkey.GetPem(false))

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

    cert.DisposeCert()
    pubkey.DisposePublicKey()