Sample code for 30+ languages & platforms
Go

Get Certificate Public Key from PEM

See more Certificates Examples

Demonstrates how to load a PEM file containing a certificate and access the public key.

Chilkat Go Downloads

Go
    success := false

    cert := chilkat.NewCert()

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

    pubkey := chilkat.NewPublicKey()
    cert.GetPublicKey(pubkey)

    // Examine the public key as XML..
    fmt.Println(*pubkey.GetXml())

    cert.DisposeCert()
    pubkey.DisposePublicKey()