@@ -26,7 +26,6 @@ import (
2626 mathrand "math/rand"
2727 "net"
2828 "net/http"
29- "net/netip"
3029 "path"
3130 "strings"
3231 "sync"
@@ -177,6 +176,14 @@ type Manager struct {
177176 // See RFC 8555, Section 7.3.4 for more details.
178177 ExternalAccountBinding * acme.ExternalAccountBinding
179178
179+ // Profile optional name of certificate profile to use when creating a new order
180+ //
181+ // available profiles are defined by the ACME server and listed in the
182+ // ACME server's directory response.
183+ //
184+ // See RFC: https://datatracker.ietf.org/doc/draft-aaron-acme-profiles/
185+ Profile string
186+
180187 clientMu sync.Mutex
181188 client * acme.Client // initialized by acmeClient method
182189
@@ -694,9 +701,16 @@ func (m *Manager) verifyRFC(ctx context.Context, client *acme.Client, domain str
694701 // it will most likely not work on another order's authorization either.
695702 challengeTypes := m .supportedChallengeTypes ()
696703 nextTyp := 0 // challengeTypes index
704+ authOpts := []acme.OrderOption {acme .WithOrderProfile (m .Profile )}
697705AuthorizeOrderLoop:
698706 for {
699- o , err := client .AuthorizeOrder (ctx , acme .DomainIDs (domain ))
707+ var ids []acme.AuthzID
708+ if ip := net .ParseIP (domain ); ip != nil {
709+ ids = acme .IPIDs (domain )
710+ } else {
711+ ids = acme .DomainIDs (domain )
712+ }
713+ o , err := client .AuthorizeOrder (ctx , ids , authOpts ... )
700714 if err != nil {
701715 return nil , err
702716 }
@@ -1061,12 +1075,14 @@ func (s *certState) tlscert() (*tls.Certificate, error) {
10611075// certRequest generates a CSR for the given common name.
10621076func certRequest (key crypto.Signer , name string , ext []pkix.Extension ) ([]byte , error ) {
10631077 req := & x509.CertificateRequest {
1064- Subject : pkix.Name {CommonName : name },
1078+ Subject : pkix.Name {},
10651079 ExtraExtensions : ext ,
10661080 }
1067- // add name to DNSNames if name is not an IP address
1068- if _ , err := netip .ParseAddr (name ); err != nil {
1081+ if ip := net .ParseIP (name ); ip != nil {
1082+ req .IPAddresses = []net.IP {ip }
1083+ } else {
10691084 req .DNSNames = []string {name }
1085+ req .Subject .CommonName = name
10701086 }
10711087 return x509 .CreateCertificateRequest (rand .Reader , req , key )
10721088}
0 commit comments