Skip to content

Commit cfc2bd4

Browse files
committed
Fix wildcard authorization reuse with DNS-Account-01
The RA rejected wildcard authorizations with DNS-Account-01 challenges during reuse, though the PA offers DNS-Account-01 for wildcards. In ra.go:2244-2248, the NewOrder() validation only accepted DNS-01 for wildcards. This check predates DNS-Account-01 wildcard support (added after commit 52615d9). Changes: - Accept both DNS-01 and DNS-Account-01 for wildcard reuse - Split validation into two checks (count vs type) - Add TestNewOrderAuthzReuseDNSAccount01 unit test The bug only affected authorization reuse (not new authorizations), which is why existing tests using random domains didn't expose it.
1 parent 9564684 commit cfc2bd4

File tree

2 files changed

+54
-7
lines changed

2 files changed

+54
-7
lines changed

ra/ra.go

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2239,13 +2239,20 @@ func (ra *RegistrationAuthorityImpl) NewOrder(ctx context.Context, req *rapb.New
22392239
}
22402240

22412241
// If the identifier is a wildcard DNS name, it must have exactly one
2242-
// DNS-01 type challenge. The PA guarantees this at order creation time,
2243-
// but we verify again to be safe.
2244-
if ident.Type == identifier.TypeDNS && strings.HasPrefix(ident.Value, "*.") &&
2245-
(len(authz.Challenges) != 1 || authz.Challenges[0].Type != core.ChallengeTypeDNS01) {
2246-
return nil, berrors.InternalServerError(
2247-
"SA.GetAuthorizations returned a DNS wildcard authz (%s) with invalid challenge(s)",
2248-
authz.ID)
2242+
// DNS-01 or DNS-Account-01 type challenge. The PA guarantees this at
2243+
// order creation time, but we verify again to be safe.
2244+
if ident.Type == identifier.TypeDNS && strings.HasPrefix(ident.Value, "*.") {
2245+
if len(authz.Challenges) != 1 {
2246+
return nil, berrors.InternalServerError(
2247+
"SA.GetAuthorizations returned a DNS wildcard authz (%s) with %d challenges, expected 1",
2248+
authz.ID, len(authz.Challenges))
2249+
}
2250+
challengeType := authz.Challenges[0].Type
2251+
if challengeType != core.ChallengeTypeDNS01 && challengeType != core.ChallengeTypeDNSAccount01 {
2252+
return nil, berrors.InternalServerError(
2253+
"SA.GetAuthorizations returned a DNS wildcard authz (%s) with invalid challenge type %s",
2254+
authz.ID, challengeType)
2255+
}
22492256
}
22502257

22512258
// If we reached this point then the existing authz was acceptable for

ra/ra_test.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2120,6 +2120,46 @@ func TestNewOrderAuthzReuseSafety(t *testing.T) {
21202120
test.AssertContains(t, err.Error(), "SA.GetAuthorizations returned a DNS wildcard authz (1) with invalid challenge(s)")
21212121
}
21222122

2123+
// TestNewOrderAuthzReuseDNSAccount01 checks that the RA correctly allows reuse
2124+
// of a wildcard authorization with a DNS-Account-01 challenge.
2125+
func TestNewOrderAuthzReuseDNSAccount01(t *testing.T) {
2126+
_, _, ra, _, _, registration, cleanUp := initAuthorities(t)
2127+
defer cleanUp()
2128+
2129+
ctx := context.Background()
2130+
idents := identifier.ACMEIdentifiers{identifier.NewDNS("*.zombo.com")}
2131+
2132+
// Use a mock SA that returns a valid DNS-Account-01 authz for wildcard
2133+
expires := time.Now().Add(24 * time.Hour)
2134+
ra.SA = &mockSAWithAuthzs{
2135+
authzs: []*core.Authorization{
2136+
{
2137+
ID: "1",
2138+
Identifier: identifier.NewDNS("*.zombo.com"),
2139+
RegistrationID: registration.Id,
2140+
Status: "valid",
2141+
Expires: &expires,
2142+
Challenges: []core.Challenge{
2143+
{
2144+
Type: core.ChallengeTypeDNSAccount01,
2145+
Status: core.StatusValid,
2146+
Token: core.NewToken(),
2147+
},
2148+
},
2149+
},
2150+
},
2151+
}
2152+
2153+
orderReq := &rapb.NewOrderRequest{
2154+
RegistrationID: registration.Id,
2155+
Identifiers: idents.ToProtoSlice(),
2156+
}
2157+
2158+
// Create an order - it should succeed with DNS-Account-01 wildcard reuse
2159+
_, err := ra.NewOrder(ctx, orderReq)
2160+
test.AssertNotError(t, err, "NewOrder failed to reuse wildcard authz with DNS-Account-01")
2161+
}
2162+
21232163
func TestNewOrderWildcard(t *testing.T) {
21242164
_, _, ra, _, _, registration, cleanUp := initAuthorities(t)
21252165
defer cleanUp()

0 commit comments

Comments
 (0)