@@ -55,23 +55,7 @@ func (iss *ACMEIssuer) newACMEClientWithAccount(ctx context.Context, useTestCA,
5555 // we try loading the account from storage before a potential
5656 // lock, and after obtaining the lock as well, to ensure we don't
5757 // repeat work done by another instance or goroutine
58- getAccount := func () (acme.Account , error ) {
59- // look up or create the ACME account
60- var account acme.Account
61- if iss .AccountKeyPEM != "" {
62- iss .Logger .Info ("using configured ACME account" )
63- account , err = iss .GetAccount (ctx , []byte (iss .AccountKeyPEM ))
64- } else {
65- account , err = iss .getAccount (ctx , client .Directory , iss .getEmail ())
66- }
67- if err != nil {
68- return acme.Account {}, fmt .Errorf ("getting ACME account: %v" , err )
69- }
70- return account , nil
71- }
72-
73- // first try getting the account
74- account , err := getAccount ()
58+ account , err := iss .getAccountToUse (ctx , client .Directory )
7559 if err != nil {
7660 return nil , err
7761 }
@@ -95,7 +79,7 @@ func (iss *ACMEIssuer) newACMEClientWithAccount(ctx context.Context, useTestCA,
9579 }()
9680
9781 // if we're not the only one waiting for this account, then by this point it should already be registered and in storage; reload it
98- account , err = getAccount ( )
82+ account , err = iss . getAccountToUse ( ctx , client . Directory )
9983 if err != nil {
10084 return nil , err
10185 }
@@ -207,26 +191,34 @@ func (iss *ACMEIssuer) newACMEClient(useTestCA bool) (*acmez.Client, error) {
207191 if iss .DNS01Solver == nil {
208192 // enable HTTP-01 challenge
209193 if ! iss .DisableHTTPChallenge {
210- client .ChallengeSolvers [acme .ChallengeTypeHTTP01 ] = distributedSolver {
211- storage : iss .config .Storage ,
212- storageKeyIssuerPrefix : iss .storageKeyCAPrefix (client .Directory ),
213- solver : & httpSolver {
214- handler : iss .HTTPChallengeHandler (http .NewServeMux ()),
215- address : net .JoinHostPort (iss .ListenHost , strconv .Itoa (iss .getHTTPPort ())),
216- },
194+ var solver acmez.Solver = & httpSolver {
195+ handler : iss .HTTPChallengeHandler (http .NewServeMux ()),
196+ address : net .JoinHostPort (iss .ListenHost , strconv .Itoa (iss .getHTTPPort ())),
197+ }
198+ if ! iss .DisableDistributedSolvers {
199+ solver = distributedSolver {
200+ storage : iss .config .Storage ,
201+ storageKeyIssuerPrefix : iss .storageKeyCAPrefix (client .Directory ),
202+ solver : solver ,
203+ }
217204 }
205+ client .ChallengeSolvers [acme .ChallengeTypeHTTP01 ] = solver
218206 }
219207
220208 // enable TLS-ALPN-01 challenge
221209 if ! iss .DisableTLSALPNChallenge {
222- client .ChallengeSolvers [acme .ChallengeTypeTLSALPN01 ] = distributedSolver {
223- storage : iss .config .Storage ,
224- storageKeyIssuerPrefix : iss .storageKeyCAPrefix (client .Directory ),
225- solver : & tlsALPNSolver {
226- config : iss .config ,
227- address : net .JoinHostPort (iss .ListenHost , strconv .Itoa (iss .getTLSALPNPort ())),
228- },
210+ var solver acmez.Solver = & tlsALPNSolver {
211+ config : iss .config ,
212+ address : net .JoinHostPort (iss .ListenHost , strconv .Itoa (iss .getTLSALPNPort ())),
213+ }
214+ if ! iss .DisableDistributedSolvers {
215+ solver = distributedSolver {
216+ storage : iss .config .Storage ,
217+ storageKeyIssuerPrefix : iss .storageKeyCAPrefix (client .Directory ),
218+ solver : solver ,
219+ }
229220 }
221+ client .ChallengeSolvers [acme .ChallengeTypeTLSALPN01 ] = solver
230222 }
231223 } else {
232224 // use DNS challenge exclusively
0 commit comments