0
0
Fork 0

implement marshal pem interface for certificates

This commit is contained in:
Gibheer 2015-03-16 17:10:46 +01:00
parent 362fe8ff38
commit 2b74dbb334
1 changed files with 10 additions and 1 deletions

View File

@ -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