How to convert *x509.Certificate into byte slice in Go

54 Views Asked by At

I've a certificate

cert := parseCert("cert.pem") // returns *x509.Certificate

Need to convert that cert into []byte so I can do the thing I want to do which requires byte slice of a certificate, like the following returns

certByte, _ := x509.CreateCertificate(...) // returns []byte (it's not PEM encoded, need like this)

How this can be done?

0

There are 0 best solutions below