Found it. The key is to use function x509.ParseCertificate(block.Bytes) .

Code below is not clean but should help anyone looking for a way to parse 
pem file into x509.Certificate.

f, err := os.Open(sn.recpCertFile)
if err != nil {
log.Fatal(err)
}
defer f.Close()

pubPEM, err := ioutil.ReadAll(f)
if err != nil {
log.Fatal(err)
}

block, _ := pem.Decode(pubPEM)
if block == nil {
log.Fatal("failed to parse PEM block containing the public key")
}

cert, err := x509.ParseCertificate(block.Bytes)
if err != nil {
log.Fatal(err)
}

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to