implement marshal pem interface for certificates
This commit is contained in:
parent
362fe8ff38
commit
2b74dbb334
|
@ -11,7 +11,10 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
const PemLabelCertificateRequest = "CERTIFICATE REQUEST"
|
const (
|
||||||
|
PemLabelCertificateRequest = "CERTIFICATE REQUEST"
|
||||||
|
PemLabelCertificate = "CERTIFICATE"
|
||||||
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
CertificateData struct {
|
CertificateData struct {
|
||||||
|
@ -111,6 +114,12 @@ func LoadCertificate(raw []byte) (*Certificate, error) {
|
||||||
return (*Certificate)(cert), nil
|
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 {
|
func (co *CertificateOptions) Valid() error {
|
||||||
if co.SerialNumber == nil { return fmt.Errorf("No serial number set!") }
|
if co.SerialNumber == nil { return fmt.Errorf("No serial number set!") }
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in New Issue