From 2ad03c8f80e048138581229bab76c481292847b4 Mon Sep 17 00:00:00 2001 From: Gibheer Date: Sun, 18 Sep 2016 17:39:29 +0200 Subject: [PATCH] move certificate and certificate request to pemmer This makes them use the Pemmer interface and therefore doesn't require any weird control code to handle these two special cases. --- certificate.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/certificate.go b/certificate.go index 424d39a..b8849d2 100644 --- a/certificate.go +++ b/certificate.go @@ -6,6 +6,7 @@ import ( "crypto/x509/pkix" "encoding/pem" "fmt" + "io" "math/big" "net" "time" @@ -81,9 +82,9 @@ func LoadCertificateSignRequest(raw []byte) (*CertificateRequest, error) { } // Return the certificate sign request as a pem block. -func (c *CertificateRequest) MarshalPem() (marshalledPemBlock, error) { +func (c *CertificateRequest) MarshalPem() (io.WriterTo, error) { block := &pem.Block{Type: PemLabelCertificateRequest, Bytes: c.Raw} - return pem.EncodeToMemory(block), nil + return marshalledPemBlock(pem.EncodeToMemory(block)), nil } // Convert the certificate sign request to a certificate using the private key @@ -152,7 +153,7 @@ func LoadCertificate(raw []byte) (*Certificate, error) { // 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 + return marshalledPemBlock(pem.EncodeToMemory(block)), nil } // Check if the certificate options have the required fields set.