@@ -685,21 +685,38 @@ private async Task ProcessAuthorizations(AcmeClient acmeClient, OrderDetails ord
685685 async ( ) => await cnameResolver . ResolveChallengeTargetAsync ( validation . DnsRecordName ) ,
686686 detail : $ "from { validation . DnsRecordName } ") ;
687687
688+ // Decide which name to resolve the DNS provider plugin against. The framework
689+ // matches validators against the (wildcard) domain patterns configured per
690+ // provider, keyed on the certificate/zone name (e.g. *.keyfactor.ssl4saas.com)
691+ // -- NOT the _acme-challenge record name. So:
692+ // * No delegation -> resolve on the cert domain (www.example.com), exactly
693+ // as before delegation support existed.
694+ // * CNAME delegated -> resolve on the terminal target (host.validation-zone),
695+ // so the provider that owns the delegation zone is chosen.
696+ // Note the resolver returns the original name unchanged when no CNAME exists,
697+ // and that original name still carries the _acme-challenge prefix, which would
698+ // not match the configured wildcard -- hence the explicit branch here.
699+ bool isDelegated = ! string . Equals (
700+ recordName ? . TrimEnd ( '.' ) ,
701+ validation . DnsRecordName ? . TrimEnd ( '.' ) ,
702+ StringComparison . OrdinalIgnoreCase ) ;
703+ var validatorLookupName = isDelegated ? recordName : domain ;
704+
688705 var domainValidator = flow . Step ( $ "ResolveValidator:{ domain } ",
689706 ( ) =>
690707 {
691- var v = _validatorFactory . ResolveDomainValidator ( recordName , DNS_CHALLENGE_TYPE ) ;
708+ var v = _validatorFactory . ResolveDomainValidator ( validatorLookupName , DNS_CHALLENGE_TYPE ) ;
692709 if ( v == null )
693710 {
694711 throw new InvalidOperationException (
695- $ "Failed to resolve domain validator for '{ recordName } ' (challenge for '{ domain } '). " +
712+ $ "Failed to resolve domain validator for '{ validatorLookupName } ' (challenge for '{ domain } '). " +
696713 "Ensure the appropriate DNS provider plugin is deployed and configured for the zone that hosts the (possibly CNAME-delegated) challenge record." ) ;
697714 }
698715 return v ;
699716 } ) ;
700717
701- _logger . LogInformation ( "Using domain validator: {ValidatorType} for record: {RecordName} ( domain: {Domain})" ,
702- domainValidator . GetType ( ) . Name , recordName , domain ) ;
718+ _logger . LogInformation ( "Using domain validator: {ValidatorType} resolved on {LookupName} ( record: {RecordName}, domain: {Domain}, delegated: {Delegated })" ,
719+ domainValidator . GetType ( ) . Name , validatorLookupName , recordName , domain , isDelegated ) ;
703720
704721 await flow . StepAsync ( $ "StageValidation:{ domain } ",
705722 async ( ) =>
0 commit comments