The certificate byte stream is available in the Raw field of the
Certificate struct.

You can for example output received certificates PEM encoded like this:

for _, c := range r.TLS.PeerCertificates {
    pem.Encode(os.Stdout, &pem.Block{Type: "CERTIFICATE", Bytes: c.Raw})
}

Or you can just save c.Raw in a file if you prefer binary format.

See https://gist.github.com/snabb/01c71af8cc9815e2fed68767bbb445af for
complete example.

Janne Snabb
sn...@epipe.com

On 2017-02-15 03:54, Naveen Shivegowda wrote:
> Hi,
> 
> I need to store the client certificates in a file for further
> authentication purpose but I am not able to re-form the client certificates.
> TLS.PeerCertificates has information related to client certificates but
> it is separated by struct fields and is not present as byte stream which
> could be written into a file, Is there any package which could take
> 'TLS.PeerCertificates' and convert it into a certificate again?
> 
> -- 
> 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 golang-nuts+unsubscr...@googlegroups.com
> <mailto:golang-nuts+unsubscr...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.

-- 
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 golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to