diff options
author | Gibheer <gibheer@gmail.com> | 2015-03-16 17:10:46 +0100 |
---|---|---|
committer | Gibheer <gibheer@gmail.com> | 2015-03-16 17:10:46 +0100 |
commit | 2b74dbb334192eb25ebd9de2d1273692797ec558 (patch) | |
tree | 33452d5144de6cc8e5f8783e293bc90112871f40 /certificate.go | |
parent | 362fe8ff381893f8396090435ae77fd0a2492b4a (diff) |
implement marshal pem interface for certificates
Diffstat (limited to 'certificate.go')
-rw-r--r-- | certificate.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/certificate.go b/certificate.go index e118833..b6fa252 100644 --- a/certificate.go +++ b/certificate.go @@ -11,7 +11,10 @@ import ( "time" ) -const PemLabelCertificateRequest = "CERTIFICATE REQUEST" +const ( + PemLabelCertificateRequest = "CERTIFICATE REQUEST" + PemLabelCertificate = "CERTIFICATE" +) type ( CertificateData struct { @@ -111,6 +114,12 @@ func LoadCertificate(raw []byte) (*Certificate, error) { return (*Certificate)(cert), nil } +// marshal the certificate to a pem block +func (c *Certificate) MarshalPem() (marshalledPemBlock, error) { + block := &pem.Block{Type: PemLabelCertificate, Bytes: c.Raw} + return pem.EncodeToMemory(block), nil +} + func (co *CertificateOptions) Valid() error { if co.SerialNumber == nil { return fmt.Errorf("No serial number set!") } return nil |