|
|
@@ -146,6 +146,15 @@ type Manager struct {
|
|
|
// is EC-based keys using the P-256 curve.
|
|
|
ForceRSA bool
|
|
|
|
|
|
+ // ExtraExtensions are used when generating a new CSR (Certificate Request),
|
|
|
+ // thus allowing customization of the resulting certificate.
|
|
|
+ // For instance, TLS Feature Extension (RFC 7633) can be used
|
|
|
+ // to prevent an OCSP downgrade attack.
|
|
|
+ //
|
|
|
+ // The field value is passed to crypto/x509.CreateCertificateRequest
|
|
|
+ // in the template's ExtraExtensions field as is.
|
|
|
+ ExtraExtensions []pkix.Extension
|
|
|
+
|
|
|
clientMu sync.Mutex
|
|
|
client *acme.Client // initialized by acmeClient method
|
|
|
|
|
|
@@ -527,7 +536,7 @@ func (m *Manager) authorizedCert(ctx context.Context, key crypto.Signer, domain
|
|
|
if err := m.verify(ctx, client, domain); err != nil {
|
|
|
return nil, nil, err
|
|
|
}
|
|
|
- csr, err := certRequest(key, domain)
|
|
|
+ csr, err := certRequest(key, domain, m.ExtraExtensions)
|
|
|
if err != nil {
|
|
|
return nil, nil, err
|
|
|
}
|
|
|
@@ -870,12 +879,12 @@ func (s *certState) tlscert() (*tls.Certificate, error) {
|
|
|
}, nil
|
|
|
}
|
|
|
|
|
|
-// certRequest creates a certificate request for the given common name cn
|
|
|
-// and optional SANs.
|
|
|
-func certRequest(key crypto.Signer, cn string, san ...string) ([]byte, error) {
|
|
|
+// certRequest generates a CSR for the given common name cn and optional SANs.
|
|
|
+func certRequest(key crypto.Signer, cn string, ext []pkix.Extension, san ...string) ([]byte, error) {
|
|
|
req := &x509.CertificateRequest{
|
|
|
- Subject: pkix.Name{CommonName: cn},
|
|
|
- DNSNames: san,
|
|
|
+ Subject: pkix.Name{CommonName: cn},
|
|
|
+ DNSNames: san,
|
|
|
+ ExtraExtensions: ext,
|
|
|
}
|
|
|
return x509.CreateCertificateRequest(rand.Reader, req, key)
|
|
|
}
|