implement marshal pem interface for certificates
This commit is contained in:
parent
362fe8ff38
commit
2b74dbb334
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue