@@ -1457,7 +1457,8 @@ func (ra *RegistrationAuthorityImpl) recordValidation(ctx context.Context, authI
14571457// countFailedValidations increments the FailedAuthorizationsPerDomainPerAccount limit.
14581458// and the FailedAuthorizationsForPausingPerDomainPerAccountTransaction limit.
14591459//
1460- // TODO(#7311): Handle IP address identifiers.
1460+ // TODO(#7311): Handle IP address identifiers properly; don't just trust that
1461+ // the value will always make sense in context.
14611462func (ra * RegistrationAuthorityImpl ) countFailedValidations (ctx context.Context , regId int64 , ident identifier.ACMEIdentifier ) error {
14621463 txn , err := ra .txnBuilder .FailedAuthorizationsPerDomainPerAccountSpendOnlyTransaction (regId , ident .Value )
14631464 if err != nil {
@@ -1506,7 +1507,8 @@ func (ra *RegistrationAuthorityImpl) countFailedValidations(ctx context.Context,
15061507// resetAccountPausingLimit resets bucket to maximum capacity for given account.
15071508// There is no reason to surface errors from this function to the Subscriber.
15081509//
1509- // TODO(#7311): Handle IP address identifiers.
1510+ // TODO(#7311): Handle IP address identifiers properly; don't just trust that
1511+ // the value will always make sense in context.
15101512func (ra * RegistrationAuthorityImpl ) resetAccountPausingLimit (ctx context.Context , regId int64 , ident identifier.ACMEIdentifier ) {
15111513 bucketKey , err := ratelimits .NewRegIdDomainBucketKey (ratelimits .FailedAuthorizationsForPausingPerDomainPerAccount , regId , ident .Value )
15121514 if err != nil {
@@ -1628,7 +1630,7 @@ func (ra *RegistrationAuthorityImpl) PerformValidation(
16281630 checkProb , checkRecords , err := ra .checkDCVAndCAA (
16291631 vaCtx ,
16301632 & vapb.PerformValidationRequest {
1631- DnsName : authz .Identifier .Value ,
1633+ Identifier : authz .Identifier .ToProto () ,
16321634 Challenge : chall ,
16331635 Authz : & vapb.AuthzMeta {Id : authz .ID , RegID : authz .RegistrationID },
16341636 ExpectedKeyAuthorization : expectedKeyAuthorization ,
@@ -1863,11 +1865,11 @@ func (ra *RegistrationAuthorityImpl) RevokeCertByApplicant(ctx context.Context,
18631865 // authorizations for all names in the cert.
18641866 logEvent .Method = "control"
18651867
1866- // TODO(#7311): Support other kinds of SANs/identifiers here.
1868+ idents := identifier . FromCert ( cert )
18671869 var authzPB * sapb.Authorizations
18681870 authzPB , err = ra .SA .GetValidAuthorizations2 (ctx , & sapb.GetValidAuthorizationsRequest {
18691871 RegistrationID : req .RegID ,
1870- Identifiers : identifier . NewDNSSlice ( cert . DNSNames ) .ToProtoSlice (),
1872+ Identifiers : idents .ToProtoSlice (),
18711873 ValidUntil : timestamppb .New (ra .clk .Now ()),
18721874 })
18731875 if err != nil {
@@ -1880,10 +1882,9 @@ func (ra *RegistrationAuthorityImpl) RevokeCertByApplicant(ctx context.Context,
18801882 return nil , err
18811883 }
18821884
1883- // TODO(#7311): TODO(#7647): Support other kinds of SANs/identifiers here.
1884- for _ , name := range cert .DNSNames {
1885- if _ , present := authzMap [identifier .NewDNS (name )]; ! present {
1886- return nil , berrors .UnauthorizedError ("requester does not control all names in cert with serial %q" , serialString )
1885+ for _ , ident := range idents {
1886+ if _ , present := authzMap [ident ]; ! present {
1887+ return nil , berrors .UnauthorizedError ("requester does not control all identifiers in cert with serial %q" , serialString )
18871888 }
18881889 }
18891890
@@ -2392,22 +2393,23 @@ func (ra *RegistrationAuthorityImpl) NewOrder(ctx context.Context, req *rapb.New
23922393 // For each of the identifiers in the order, if there is an acceptable
23932394 // existing authz, append it to the order to reuse it. Otherwise track that
23942395 // there is a missing authz for that identifier.
2395- //
2396- // TODO(#7311): TODO(#7647): Support non-dnsName identifier types here.
23972396 var newOrderAuthzs []int64
23982397 var missingAuthzIdents identifier.ACMEIdentifiers
23992398 for _ , ident := range idents {
2400- name := ident .Value
24012399 // If there isn't an existing authz, note that its missing and continue
24022400 authz , exists := identToExistingAuthz [ident ]
24032401 if ! exists {
2402+ // The existing authz was not acceptable for reuse, and we need to
2403+ // mark the name as requiring a new pending authz.
24042404 missingAuthzIdents = append (missingAuthzIdents , ident )
24052405 continue
24062406 }
24072407
24082408 // If the authz is associated with the wrong profile, don't reuse it.
24092409 if authz .CertificateProfileName != req .CertificateProfileName {
24102410 missingAuthzIdents = append (missingAuthzIdents , ident )
2411+ // Delete the authz from the identToExistingAuthz map since we are not reusing it.
2412+ delete (identToExistingAuthz , ident )
24112413 continue
24122414 }
24132415
@@ -2417,40 +2419,28 @@ func (ra *RegistrationAuthorityImpl) NewOrder(ctx context.Context, req *rapb.New
24172419 authzAge = (profile .pendingAuthzLifetime - authz .Expires .Sub (ra .clk .Now ())).Seconds ()
24182420 }
24192421
2420- // If the identifier is a wildcard and the existing authz only has one
2421- // DNS-01 type challenge we can reuse it. In theory we will
2422- // never get back an authorization for a domain with a wildcard prefix
2423- // that doesn't meet this criteria from SA.GetAuthorizations but we verify
2424- // again to be safe.
2425- if strings .HasPrefix (name , "*." ) &&
2426- len (authz .Challenges ) == 1 && authz .Challenges [0 ].Type == core .ChallengeTypeDNS01 {
2427- authzID , err := strconv .ParseInt (authz .ID , 10 , 64 )
2428- if err != nil {
2429- return nil , err
2430- }
2431- newOrderAuthzs = append (newOrderAuthzs , authzID )
2432- ra .authzAges .WithLabelValues ("NewOrder" , string (authz .Status )).Observe (authzAge )
2433- continue
2434- } else if ! strings .HasPrefix (name , "*." ) {
2435- // If the identifier isn't a wildcard, we can reuse any authz
2436- authzID , err := strconv .ParseInt (authz .ID , 10 , 64 )
2437- if err != nil {
2438- return nil , err
2439- }
2440- newOrderAuthzs = append (newOrderAuthzs , authzID )
2441- ra .authzAges .WithLabelValues ("NewOrder" , string (authz .Status )).Observe (authzAge )
2442- continue
2422+ // If the identifier is a wildcard DNS name, it must have exactly one
2423+ // DNS-01 type challenge. The PA guarantees this at order creation time,
2424+ // but we verify again to be safe.
2425+ if ident .Type == identifier .TypeDNS && strings .HasPrefix (ident .Value , "*." ) &&
2426+ (len (authz .Challenges ) != 1 || authz .Challenges [0 ].Type != core .ChallengeTypeDNS01 ) {
2427+ return nil , berrors .InternalServerError (
2428+ "SA.GetAuthorizations returned a DNS wildcard authz (%s) with invalid challenge(s)" ,
2429+ authz .ID )
24432430 }
24442431
2445- // Delete the authz from the identToExistingAuthz map since we are not reusing it.
2446- delete (identToExistingAuthz , ident )
2447- // If we reached this point then the existing authz was not acceptable for
2448- // reuse and we need to mark the name as requiring a new pending authz
2449- missingAuthzIdents = append (missingAuthzIdents , ident )
2432+ // If we reached this point then the existing authz was acceptable for
2433+ // reuse.
2434+ authzID , err := strconv .ParseInt (authz .ID , 10 , 64 )
2435+ if err != nil {
2436+ return nil , err
2437+ }
2438+ newOrderAuthzs = append (newOrderAuthzs , authzID )
2439+ ra .authzAges .WithLabelValues ("NewOrder" , string (authz .Status )).Observe (authzAge )
24502440 }
24512441
2452- // Loop through each of the names missing authzs and create a new pending
2453- // authorization for each.
2442+ // Loop through each of the identifiers missing authzs and create a new
2443+ // pending authorization for each.
24542444 var newAuthzs []* sapb.NewAuthzRequest
24552445 for _ , ident := range missingAuthzIdents {
24562446 challTypes , err := ra .PA .ChallengeTypesFor (ident )
0 commit comments