aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--certificate.go11
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