@@ -146,6 +146,15 @@ type Manager struct {
146146 // is EC-based keys using the P-256 curve.
147147 ForceRSA bool
148148
149+ // ExtraExtensions are used when generating a new CSR (Certificate Request),
150+ // thus allowing customization of the resulting certificate.
151+ // For instance, TLS Feature Extension (RFC 7633) can be used
152+ // to prevent an OCSP downgrade attack.
153+ //
154+ // The field value is passed to crypto/x509.CreateCertificateRequest
155+ // in the template's ExtraExtensions field as is.
156+ ExtraExtensions []pkix.Extension
157+
149158 clientMu sync.Mutex
150159 client * acme.Client // initialized by acmeClient method
151160
@@ -527,7 +536,7 @@ func (m *Manager) authorizedCert(ctx context.Context, key crypto.Signer, domain
527536 if err := m .verify (ctx , client , domain ); err != nil {
528537 return nil , nil , err
529538 }
530- csr , err := certRequest (key , domain )
539+ csr , err := certRequest (key , domain , m . ExtraExtensions )
531540 if err != nil {
532541 return nil , nil , err
533542 }
@@ -870,12 +879,12 @@ func (s *certState) tlscert() (*tls.Certificate, error) {
870879 }, nil
871880}
872881
873- // certRequest creates a certificate request for the given common name cn
874- // and optional SANs.
875- func certRequest (key crypto.Signer , cn string , san ... string ) ([]byte , error ) {
882+ // certRequest generates a CSR for the given common name cn and optional SANs.
883+ func certRequest (key crypto.Signer , cn string , ext []pkix.Extension , san ... string ) ([]byte , error ) {
876884 req := & x509.CertificateRequest {
877- Subject : pkix.Name {CommonName : cn },
878- DNSNames : san ,
885+ Subject : pkix.Name {CommonName : cn },
886+ DNSNames : san ,
887+ ExtraExtensions : ext ,
879888 }
880889 return x509 .CreateCertificateRequest (rand .Reader , req , key )
881890}
0 commit comments