Skip to content

Commit 1278679

Browse files
authored
Handle mismatched URLs in key rollover. (letsencrypt#4752)
Fixes letsencrypt#4751
1 parent aad43e4 commit 1278679

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

wfe2/verify.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ func (wfe *WebFrontEndImpl) validKeyRollover(
725725
// payload already.
726726

727727
// Verify that the outer and inner JWS protected URL headers match
728-
if wfe.matchJWSURLs(outerJWS, innerJWS) != nil {
728+
if prob := wfe.matchJWSURLs(outerJWS, innerJWS); prob != nil {
729729
return nil, prob
730730
}
731731

wfe2/verify_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func pubKeyForKey(t *testing.T, privKey interface{}) interface{} {
6767
return nil
6868
}
6969

70-
// signRequestEmbed creates a JWS for aa given request body with an embedded JWK
70+
// signRequestEmbed creates a JWS for a given request body with an embedded JWK
7171
// corresponding to the private key provided. The URL and nonce extra headers
7272
// are set based on the additional arguments. A computed JWS, the corresponding
7373
// embedded JWK and the JWS in serialized string form are returned.

wfe2/wfe_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2521,6 +2521,26 @@ func TestKeyRollover(t *testing.T) {
25212521
}
25222522
}
25232523

2524+
func TestKeyRolloverMismatchedJWSURLs(t *testing.T) {
2525+
responseWriter := httptest.NewRecorder()
2526+
wfe, _ := setupWFE(t)
2527+
2528+
newKeyBytes, err := ioutil.ReadFile("../test/test-key-5.der")
2529+
test.AssertNotError(t, err, "Failed to read ../test/test-key-5.der")
2530+
newKeyPriv, err := x509.ParsePKCS1PrivateKey(newKeyBytes)
2531+
test.AssertNotError(t, err, "Failed parsing private key")
2532+
2533+
_, _, inner := signRequestEmbed(t, newKeyPriv, "http://localhost/wrong-url", "{}", wfe.nonceService)
2534+
_, _, outer := signRequestKeyID(t, 1, nil, "http://localhost/key-change", inner, wfe.nonceService)
2535+
wfe.KeyRollover(ctx, newRequestEvent(), responseWriter, makePostRequestWithPath("key-change", outer))
2536+
test.AssertUnmarshaledEquals(t, responseWriter.Body.String(), `
2537+
{
2538+
"type": "urn:ietf:params:acme:error:malformed",
2539+
"detail": "Outer JWS 'url' value \"http://localhost/key-change\" does not match inner JWS 'url' value \"http://localhost/wrong-url\"",
2540+
"status": 400
2541+
}`)
2542+
}
2543+
25242544
func TestGetOrder(t *testing.T) {
25252545
wfe, _ := setupWFE(t)
25262546

0 commit comments

Comments
 (0)