WFE2: Don't allow finalizing pending orders.

We've been using the "ready" order status for longer than the lifetime
of any previously "pending" orders. We can drop this legacy and enforce
finalization only occur for "ready" orders per-spec.
This commit is contained in:
Daniel 2019-02-21 10:06:35 -05:00
parent b88681737a
commit c85d4b097b
No known key found for this signature in database
GPG Key ID: 08FB2BFC470E75B4
3 changed files with 10 additions and 27 deletions

View File

@ -515,10 +515,10 @@ func (sa *StorageAuthority) GetOrder(_ context.Context, req *sapb.OrderRequest)
validOrder.RegistrationID = &six validOrder.RegistrationID = &six
} }
// Order ID 7 is expired // Order ID 7 is ready, but expired
if *req.Id == 7 { if *req.Id == 7 {
pending := string(core.StatusPending) ready := string(core.StatusReady)
validOrder.Status = &pending validOrder.Status = &ready
exp = sa.clk.Now().AddDate(-30, 0, 0).Unix() exp = sa.clk.Now().AddDate(-30, 0, 0).Unix()
validOrder.Expires = &exp validOrder.Expires = &exp
} }

View File

@ -1805,13 +1805,8 @@ func (wfe *WebFrontEndImpl) FinalizeOrder(ctx context.Context, logEvent *web.Req
return return
} }
// Prior to ACME draft-10 the "ready" status did not exist and orders in // Only ready orders can be finalized.
// a pending status with valid authzs were finalizable. We accept both states if *order.Status != string(core.StatusReady) {
// here for deployability ease. In the future we will only allow ready orders
// to be finalized.
// TODO(@cpu): Forbid finalizing "Pending" orders
if *order.Status != string(core.StatusPending) &&
*order.Status != string(core.StatusReady) {
wfe.sendError(response, logEvent, wfe.sendError(response, logEvent,
probs.Malformed( probs.Malformed(
"Order's status (%q) is not acceptable for finalization", "Order's status (%q) is not acceptable for finalization",

View File

@ -2174,21 +2174,9 @@ func TestFinalizeOrder(t *testing.T) {
ExpectedBody: `{"type":"` + probs.V2ErrorNS + `malformed","detail":"Order 7 is expired","status":404}`, ExpectedBody: `{"type":"` + probs.V2ErrorNS + `malformed","detail":"Order 7 is expired","status":404}`,
}, },
{ {
Name: "Good CSR, Pending Order", Name: "Good CSR, Pending Order",
Request: signAndPost(t, "1/4", "http://localhost/1/4", goodCertCSRPayload, 1, wfe.nonceService), Request: signAndPost(t, "1/4", "http://localhost/1/4", goodCertCSRPayload, 1, wfe.nonceService),
ExpectedHeaders: map[string]string{"Location": "http://localhost/acme/order/1/4"}, ExpectedBody: `{"type":"` + probs.V2ErrorNS + `malformed","detail":"Order's status (\"pending\") is not acceptable for finalization","status":400}`,
ExpectedBody: `
{
"status": "processing",
"expires": "1970-01-01T00:00:00.9466848Z",
"identifiers": [
{"type":"dns","value":"example.com"}
],
"authorizations": [
"http://localhost/acme/authz/hello"
],
"finalize": "http://localhost/acme/finalize/1/4"
}`,
}, },
{ {
Name: "Good CSR, Ready Order", Name: "Good CSR, Ready Order",
@ -2229,7 +2217,7 @@ func TestFinalizeOrder(t *testing.T) {
// to match the whole response body because the "detail" of a bad CSR problem // to match the whole response body because the "detail" of a bad CSR problem
// contains a verbose Go error message that can change between versions (e.g. // contains a verbose Go error message that can change between versions (e.g.
// Go 1.10.4 to 1.11 changed the expected format) // Go 1.10.4 to 1.11 changed the expected format)
badCSRReq := signAndPost(t, "1/4", "http://localhost/1/4", `{"CSR": "ABCD"}`, 1, wfe.nonceService) badCSRReq := signAndPost(t, "1/8", "http://localhost/1/8", `{"CSR": "ABCD"}`, 1, wfe.nonceService)
responseWriter.Body.Reset() responseWriter.Body.Reset()
responseWriter.HeaderMap = http.Header{} responseWriter.HeaderMap = http.Header{}
wfe.FinalizeOrder(ctx, newRequestEvent(), responseWriter, badCSRReq) wfe.FinalizeOrder(ctx, newRequestEvent(), responseWriter, badCSRReq)
@ -2819,7 +2807,7 @@ func TestFinalizeSCTError(t *testing.T) {
}` }`
// Create a finalization request with the above payload // Create a finalization request with the above payload
request := signAndPost(t, "1/4", "http://localhost/1/4", goodCertCSRPayload, 1, wfe.nonceService) request := signAndPost(t, "1/8", "http://localhost/1/8", goodCertCSRPayload, 1, wfe.nonceService)
// POST the finalize order request. // POST the finalize order request.
wfe.FinalizeOrder(ctx, newRequestEvent(), responseWriter, request) wfe.FinalizeOrder(ctx, newRequestEvent(), responseWriter, request)