provide more documentation for certificate types
This commit is contained in:
parent
491630e33f
commit
b3f621a312
|
@ -11,12 +11,15 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// labels used in the pem file format to mark certificate sign requests and certificates
|
||||||
const (
|
const (
|
||||||
PemLabelCertificateRequest = "CERTIFICATE REQUEST"
|
PemLabelCertificateRequest = "CERTIFICATE REQUEST"
|
||||||
PemLabelCertificate = "CERTIFICATE"
|
PemLabelCertificate = "CERTIFICATE"
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
|
// Use CertificateData to fill in the minimum data you need to create a certificate
|
||||||
|
// sign request.
|
||||||
CertificateData struct {
|
CertificateData struct {
|
||||||
Subject pkix.Name
|
Subject pkix.Name
|
||||||
|
|
||||||
|
@ -25,9 +28,13 @@ type (
|
||||||
IPAddresses []net.IP
|
IPAddresses []net.IP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Certificate is an alias on the x509.Certificate to add some methods.
|
||||||
Certificate x509.Certificate
|
Certificate x509.Certificate
|
||||||
|
// CertificateRequest is an alias on the x509.CertificateRequest to add some methods.
|
||||||
CertificateRequest x509.CertificateRequest
|
CertificateRequest x509.CertificateRequest
|
||||||
|
|
||||||
|
// CertificateOptions is used to provide the necessary information to create
|
||||||
|
// a certificate from a certificate sign request.
|
||||||
CertificateOptions struct {
|
CertificateOptions struct {
|
||||||
SerialNumber *big.Int
|
SerialNumber *big.Int
|
||||||
NotBefore time.Time
|
NotBefore time.Time
|
||||||
|
@ -40,6 +47,7 @@ type (
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Create a new set of certificate data.
|
||||||
func NewCertificateData() *CertificateData {
|
func NewCertificateData() *CertificateData {
|
||||||
return &CertificateData{Subject: pkix.Name{}}
|
return &CertificateData{Subject: pkix.Name{}}
|
||||||
}
|
}
|
||||||
|
@ -133,6 +141,7 @@ func (c *Certificate) MarshalPem() (marshalledPemBlock, error) {
|
||||||
return pem.EncodeToMemory(block), nil
|
return pem.EncodeToMemory(block), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if the certificate options have the required fields set.
|
||||||
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