Skip to content

Commit 53c35ac

Browse files
authored
WFE: Return errors from JWS-verification functions (#8077)
Change all of the helper methods and functions in verify.go to return an `error` instead of a `probs.ProblemDetails`. Add a few new types to our errors package, and support for those types in ProblemDetailsForError, to maintain the same public-facing error types. Update the tests to check for specific errors instead of specific problems. This is a building block towards making the probs.ProblemDetails type not implement the Error interface, and only be used when rendering errors to the user (i.e. not within Boulder logic itself). Part of #4980
1 parent 8b1a87e commit 53c35ac

7 files changed

Lines changed: 812 additions & 789 deletions

File tree

errors/errors.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const (
3131
// InternalServer is deprecated. Instead, pass a plain Go error. That will get
3232
// turned into a probs.InternalServerError by the WFE.
3333
InternalServer ErrorType = iota
34-
_
34+
_ // Reserved, previously NotSupported
3535
Malformed
3636
Unauthorized
3737
NotFound
@@ -58,6 +58,9 @@ const (
5858
// The certificate being indicated for replacement already has a replacement
5959
// order.
6060
AlreadyReplaced
61+
BadSignatureAlgorithm
62+
AccountDoesNotExist
63+
BadNonce
6164
)
6265

6366
func (ErrorType) Error() string {
@@ -303,3 +306,15 @@ func UnknownSerialError() error {
303306
func InvalidProfileError(msg string, args ...interface{}) error {
304307
return newf(InvalidProfile, msg, args...)
305308
}
309+
310+
func BadSignatureAlgorithmError(msg string, args ...interface{}) error {
311+
return newf(BadSignatureAlgorithm, msg, args...)
312+
}
313+
314+
func AccountDoesNotExistError(msg string, args ...interface{}) error {
315+
return newf(AccountDoesNotExist, msg, args...)
316+
}
317+
318+
func BadNonceError(msg string, args ...interface{}) error {
319+
return newf(BadNonce, msg, args...)
320+
}

test/integration/revocation_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ func TestRevokeWithKeyCompromiseBlocksKey(t *testing.T) {
536536
test.AssertNotError(t, err, "NewAccount failed with a non-blocklisted key")
537537
case byKey:
538538
test.AssertError(t, err, "NewAccount didn't fail with a blocklisted key")
539-
test.AssertEquals(t, err.Error(), `acme: error code 400 "urn:ietf:params:acme:error:badPublicKey": public key is forbidden`)
539+
test.AssertEquals(t, err.Error(), `acme: error code 400 "urn:ietf:params:acme:error:badPublicKey": Unable to validate JWS :: invalid request signing key: public key is forbidden`)
540540
}
541541
}
542542
}

web/probs.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ func problemDetailsForBoulderError(err *berrors.BoulderError, msg string) *probs
5252
outProb = probs.Conflict(fmt.Sprintf("%s :: %s", msg, err))
5353
case berrors.InvalidProfile:
5454
outProb = probs.InvalidProfile(fmt.Sprintf("%s :: %s", msg, err))
55+
case berrors.BadSignatureAlgorithm:
56+
outProb = probs.BadSignatureAlgorithm(fmt.Sprintf("%s :: %s", msg, err))
57+
case berrors.AccountDoesNotExist:
58+
outProb = probs.AccountDoesNotExist(fmt.Sprintf("%s :: %s", msg, err))
59+
case berrors.BadNonce:
60+
outProb = probs.BadNonce(fmt.Sprintf("%s :: %s", msg, err))
5561
default:
5662
// Internal server error messages may include sensitive data, so we do
5763
// not include it.

wfe2/verify.go

Lines changed: 149 additions & 160 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)