Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/crypto/acme: allow OrderFinalization requests to respond with StatusCreated #38626

Closed
dandragona-dev opened this issue Apr 23, 2020 · 2 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@dandragona-dev
Copy link

dandragona-dev commented Apr 23, 2020

What version of Go are you using (go version)?

go version go1.14 linux/amd64

Does this issue reproduce with the latest release?

I believe so.

What operating system and processor architecture are you using (go env)?

go env Output
"linux"
"amd64"

What did you do?

I am using the acme client to perform an RFC8555 compliant workflow. The RFC specifies that NewAccount and OrderFinalization requests to respond with StatusCreated. The rfc8555.go file only accepts StatusOK responses.

A quick and easy solution would be adding StatusCreated to the following line in CreateOrderCert:
Line 295: res, err := c.post(ctx, nil, url, req, wantStatus(http.StatusOK, http.StatusCreated))

The test for this function then needs to be updated so that the /pleaseissue handler is broken up into two handlers. One for the order finalization, and one for the order polling since these two requests now expect different server responses.
Something like:

s.handle("/acme/new-account", func(w http.ResponseWriter, r *http.Request) {
	w.Header().Set("Location", s.url("/accounts/1"))
	w.WriteHeader(http.StatusCreated)
	w.Write([]byte(`{"status": "valid"}`))
})
s.handle("/pleaseissue", func(w http.ResponseWriter, r *http.Request) {
	w.Header().Set("Location", s.url("/orders/1"))
	w.WriteHeader(http.StatusCreated)
	fmt.Fprintf(w, `{"status":%q, "certificate":%q}`, StatusProcessing, s.url("/crt"))
})
s.handle("/orders/1", func(w http.ResponseWriter, r *http.Request) {
	w.Header().Set("Location", s.url("/orders/1"))
	w.WriteHeader(http.StatusOK)
	fmt.Fprintf(w, `{"status": %q, "certificate":%q}`, StatusValid, s.url("/crt"))
})
s.handle("/crt", func(w http.ResponseWriter, r *http.Request) {
	w.Header().Set("Content-Type", "application/pem-certificate-chain")
	pem.Encode(w, &pem.Block{Type: "CERTIFICATE", Bytes: leaf})
})
@gopherbot gopherbot added this to the Unreleased milestone Apr 23, 2020
@dmitshur dmitshur changed the title x/crypto allow OrderFinalization requests to respond with StatusCreated x/crypto: allow OrderFinalization requests to respond with StatusCreated Apr 23, 2020
@andybons andybons changed the title x/crypto: allow OrderFinalization requests to respond with StatusCreated x/crypto/acme: allow OrderFinalization requests to respond with StatusCreated Apr 24, 2020
@andybons
Copy link
Member

@katiehockman @FiloSottile

@andybons andybons added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Apr 24, 2020
@dandragona-dev
Copy link
Author

I misinterpreted the RFC this is actually working as intended.

@golang golang locked and limited conversation to collaborators Apr 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants