@@ -316,13 +316,6 @@ func (cfg *Config) getCertDuringHandshake(ctx context.Context, hello *tls.Client
316
316
}()
317
317
}
318
318
319
- // Make sure a certificate is allowed for the given name. If not, it doesn't
320
- // make sense to try loading one from storage (issue #185), getting it from a
321
- // certificate manager, or obtaining one from an issuer.
322
- if err := cfg .checkIfCertShouldBeObtained (ctx , name , false ); err != nil {
323
- return Certificate {}, fmt .Errorf ("certificate is not allowed for server name %s: %w" , name , err )
324
- }
325
-
326
319
// If an external Manager is configured, try to get it from them.
327
320
// Only continue to use our own logic if it returns empty+nil.
328
321
externalCert , err := cfg .getCertFromAnyCertManager (ctx , hello , logger )
@@ -333,6 +326,12 @@ func (cfg *Config) getCertDuringHandshake(ctx context.Context, hello *tls.Client
333
326
return externalCert , nil
334
327
}
335
328
329
+ // Make sure a certificate is allowed for the given name. If not, it doesn't make sense
330
+ // to try loading one from storage (issue #185) or obtaining one from an issuer.
331
+ if err := cfg .checkIfCertShouldBeObtained (ctx , name , false ); err != nil {
332
+ return Certificate {}, fmt .Errorf ("certificate is not allowed for server name %s: %w" , name , err )
333
+ }
334
+
336
335
// We might be able to load or obtain a needed certificate. Load from
337
336
// storage if OnDemand is enabled, or if there is the possibility that
338
337
// a statically-managed cert was evicted from a full cache.
0 commit comments