Documentation
¶
Overview ¶
Package initca contains code to initialise a certificate authority, generating a new root key and certificate.
Index ¶
- Variables
- func New(req *csr.CertificateRequest) (cert, csrPEM, key []byte, err error)
- func NewFromPEM(req *csr.CertificateRequest, keyFile string) (cert, csrPEM []byte, err error)
- func NewFromSigner(req *csr.CertificateRequest, priv crypto.Signer) (cert, csrPEM []byte, err error)
- func NewUnsigned(req *csr.CertificateRequest) (cert, key []byte, err error)
- func NewUnsignedFromSigner(req *csr.CertificateRequest, priv crypto.Signer) (cert []byte, err error)
- func RenewFromPEM(caFile, keyFile string) ([]byte, error)
- func RenewFromSigner(ca *x509.Certificate, priv crypto.Signer) ([]byte, error)
- func Unsign(certPEM []byte) ([]byte, error)
- func Update(ca *x509.Certificate, priv crypto.Signer) (cert []byte, err error)
Constants ¶
This section is empty.
Variables ¶
var CAPolicy = func() *config.Signing { return &config.Signing{ Default: &config.SigningProfile{ Usage: []string{"cert sign", "crl sign"}, ExpiryString: "43800h", Expiry: 5 * helpers.OneYear, CAConstraint: config.CAConstraint{IsCA: true}, }, } }
CAPolicy contains the CA issuing policy as default policy.
Functions ¶
func New ¶
func New(req *csr.CertificateRequest) (cert, csrPEM, key []byte, err error)
New creates a new root certificate from the certificate request.
func NewFromPEM ¶
func NewFromPEM(req *csr.CertificateRequest, keyFile string) (cert, csrPEM []byte, err error)
NewFromPEM creates a new root certificate from the key file passed in.
func NewFromSigner ¶
func NewFromSigner(req *csr.CertificateRequest, priv crypto.Signer) (cert, csrPEM []byte, err error)
NewFromSigner creates a new root certificate from a crypto.Signer.
func NewUnsigned ¶ added in v1.7.2
func NewUnsigned(req *csr.CertificateRequest) (cert, key []byte, err error)
NewUnsigned is New followed by Unsign. req.RawSubject must be set; the returned certificate is an RFC 9925 unsigned root whose subject and issuer are req.RawSubject. req.Hosts is ignored, so the root has no SANs.
func NewUnsignedFromSigner ¶ added in v1.7.2
func NewUnsignedFromSigner(req *csr.CertificateRequest, priv crypto.Signer) (cert []byte, err error)
NewUnsignedFromSigner returns an RFC 9925 unsigned root for the public key of priv, with the same request rules as NewUnsigned. req.KeyRequest is ignored.
Most signers that do not hold the key they report fail earlier, when the CSR or the certificate is signed. After priv signs the certificate, the signature is checked under the certificate's own public key, which fails with a KeyMismatch error for a signer whose Public result changes between operations.
func RenewFromPEM ¶
RenewFromPEM re-creates a root certificate from the CA cert and key files. The resulting root certificate will have the input CA certificate as the template and have the same expiry length. E.g. the existing CA is valid for a year from Jan 01 2015 to Jan 01 2016, the renewed certificate will be valid from now and expire in one year as well.
func RenewFromSigner ¶
RenewFromSigner re-creates a root certificate from the CA cert and crypto.Signer. The resulting root certificate will have ca certificate as the template and have the same expiry length. E.g. the existing CA is valid for a year from Jan 01 2015 to Jan 01 2016, the renewed certificate will be valid from now and expire in one year as well. An RFC 9925 unsigned certificate is rejected, because renewal would produce a signed certificate.
func Unsign ¶ added in v1.7.2
Unsign converts a PEM-encoded certificate into an RFC 9925 unsigned certificate: TBSCertificate.signature and signatureAlgorithm become id-alg-unsigned with absent parameters and signatureValue becomes an empty BIT STRING. The authority key identifier and issuer alternative name extensions are removed, as RFC 9925, Section 3.3 says senders should omit them. All other fields, including the issuer, are preserved byte for byte.
The input can be a root, an intermediate or an end-entity certificate. The input signature is not verified, so the caller is responsible for deciding that the certificate is trusted, for example because it is about to be installed directly as a trust anchor. The input must parse as an X.509 version 3 certificate. A certificate whose issuer has no attributes is rejected, because X.509 and RFC 5280 forbid an empty issuer (RFC 9925, Section 3.2). A certificate with an issuerUniqueID is rejected, because RFC 9925, Section 3.2 requires senders to omit it.
Types ¶
This section is empty.