Skip to content

Commit 0d9b48e

Browse files
Roland Bracewell ShoemakerDaniel McCarney
authored andcommitted
PA: restructure error for single bad name in multi-name req (letsencrypt#4319)
1 parent c8dbbf0 commit 0d9b48e

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

policy/pa.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -346,16 +346,22 @@ func (pa *AuthorityImpl) WillingToIssueWildcards(idents []identifier.ACMEIdentif
346346
}
347347
}
348348
if len(subErrors) > 0 {
349-
var detail string
350349
// If there was only one error, then use it as the top level error that is
351350
// returned.
352351
if len(subErrors) == 1 {
353-
return subErrors[0].BoulderError
352+
return berrors.RejectedIdentifierError(
353+
"Cannot issue for %q: %s",
354+
subErrors[0].Identifier.Value,
355+
subErrors[0].BoulderError.Detail,
356+
)
354357
}
355358

356-
detail = fmt.Sprintf("Policy forbids issuing for %q and %d more identifiers. "+
357-
"Refer to sub-problems for more information",
358-
firstBadIdent.Value, len(subErrors)-1)
359+
detail := fmt.Sprintf(
360+
"Cannot issue for %q: %s (and %d more problems. Refer to sub-problems for more information.)",
361+
firstBadIdent.Value,
362+
subErrors[0].BoulderError.Detail,
363+
len(subErrors)-1,
364+
)
359365
return (&berrors.BoulderError{
360366
Type: berrors.RejectedIdentifier,
361367
Detail: detail,

policy/pa_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ func TestWillingToIssueWildcards(t *testing.T) {
338338
berr, ok := err.(*berrors.BoulderError)
339339
test.AssertEquals(t, ok, true)
340340
test.AssertEquals(t, len(berr.SubErrors), 2)
341+
test.AssertEquals(t, berr.Error(), "Cannot issue for \"ok.*.this.is.a.*.weird.one.com\": Policy forbids issuing for name (and 1 more problems. Refer to sub-problems for more information.)")
341342

342343
subErrMap := make(map[string]berrors.SubBoulderError, len(berr.SubErrors))
343344

@@ -364,6 +365,7 @@ func TestWillingToIssueWildcards(t *testing.T) {
364365
test.AssertEquals(t, ok, true)
365366
// There should be *no* suberrors because there was only one error overall.
366367
test.AssertEquals(t, len(berr.SubErrors), 0)
368+
test.AssertEquals(t, berr.Error(), "Cannot issue for \"letsdecrypt.org\": Policy forbids issuing for name")
367369
}
368370

369371
var accountKeyJSON = `{

ra/ra_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2092,7 +2092,7 @@ func TestNewOrder(t *testing.T) {
20922092
Names: []string{"a"},
20932093
})
20942094
test.AssertError(t, err, "NewOrder with invalid names did not error")
2095-
test.AssertEquals(t, err.Error(), "DNS name does not have enough labels")
2095+
test.AssertEquals(t, err.Error(), "Cannot issue for \"a\": DNS name does not have enough labels")
20962096
}
20972097

20982098
// TestNewOrderLegacyAuthzReuse tests that a legacy acme v1 authorization from
@@ -3110,7 +3110,7 @@ func TestFinalizeOrder(t *testing.T) {
31103110
},
31113111
Csr: policyForbidCSR,
31123112
},
3113-
ExpectedErrMsg: "Policy forbids issuing for name",
3113+
ExpectedErrMsg: "Cannot issue for \"example.org\": Policy forbids issuing for name",
31143114
},
31153115
{
31163116
Name: "Order with missing registration",

test/v2_integration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,7 @@ def test_new_order_policy_errs():
935935
ok = True
936936
if e.typ != "urn:ietf:params:acme:error:rejectedIdentifier":
937937
raise(Exception('Expected rejectedIdentifier type problem, got {0}'.format(e.typ)))
938-
if e.detail != 'Error creating new order :: Policy forbids issuing for "out-addr.in-addr.arpa" and 1 more identifiers. Refer to sub-problems for more information':
938+
if e.detail != 'Error creating new order :: Cannot issue for "out-addr.in-addr.arpa": Policy forbids issuing for name (and 1 more problems. Refer to sub-problems for more information.)':
939939
raise(Exception('Order problem detail did not match expected'))
940940
if not ok:
941941
raise(Exception('Expected problem, got no error'))

0 commit comments

Comments
 (0)