Skip to content

Commit

Permalink
RA: Don't reuse authzs with mismatched profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
aarongable committed Jan 21, 2025
1 parent a620455 commit dc6073a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
5 changes: 5 additions & 0 deletions ra/ra.go
Original file line number Diff line number Diff line change
Expand Up @@ -2155,6 +2155,11 @@ func (ra *RegistrationAuthorityImpl) NewOrder(ctx context.Context, req *rapb.New
missingAuthzIdents = append(missingAuthzIdents, ident)
continue
}
// If the authz is associated with the wrong profile, don't reuse it.
if authz.CertificateProfileName != req.CertificateProfileName {
missingAuthzIdents = append(missingAuthzIdents, ident)
continue
}
authzAge := (ra.authorizationLifetime - authz.Expires.Sub(ra.clk.Now())).Seconds()
// If the identifier is a wildcard and the existing authz only has one
// DNS-01 type challenge we can reuse it. In theory we will
Expand Down
17 changes: 13 additions & 4 deletions ra/ra_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1378,10 +1378,10 @@ func TestNewOrder(t *testing.T) {
test.AssertEquals(t, err.Error(), "Cannot issue for \"a\": Domain name needs at least one dot")
}

// TestNewOrderReuse tests that subsequent requests by an ACME account to create
// TestNewOrder_OrderReuse tests that subsequent requests by an ACME account to create
// an identical order results in only one order being created & subsequently
// reused.
func TestNewOrder_OrderReusex(t *testing.T) {
func TestNewOrder_OrderReuse(t *testing.T) {
_, _, ra, _, _, cleanUp := initAuthorities(t)
defer cleanUp()

Expand Down Expand Up @@ -1589,6 +1589,7 @@ func TestNewOrder_AuthzReuse(t *testing.T) {
Name string
RegistrationID int64
DnsName string
Profile string
ExpectReuse bool
}{
{
Expand All @@ -1609,6 +1610,13 @@ func TestNewOrder_AuthzReuse(t *testing.T) {
DnsName: invalid,
ExpectReuse: false,
},
{
Name: "Don't reuse valid authz with wrong profile",
RegistrationID: Registration.Id,
DnsName: valid,
Profile: "test",
ExpectReuse: false,
},
{
Name: "Don't reuse valid authz from other acct",
RegistrationID: secondReg.Id,
Expand All @@ -1620,8 +1628,9 @@ func TestNewOrder_AuthzReuse(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.Name, func(t *testing.T) {
new, err := ra.NewOrder(context.Background(), &rapb.NewOrderRequest{
RegistrationID: tc.RegistrationID,
DnsNames: []string{tc.DnsName},
RegistrationID: tc.RegistrationID,
DnsNames: []string{tc.DnsName},
CertificateProfileName: tc.Profile,
})
test.AssertNotError(t, err, "creating test order")
test.AssertNotEquals(t, new.Id, extant.Id)
Expand Down

0 comments on commit dc6073a

Please sign in to comment.