Skip to content

Support user-defined challenge Accept payload #305

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

Closed
wants to merge 6 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions acme/acme.go
Original file line number Diff line number Diff line change
Expand Up @@ -510,15 +510,20 @@ func (c *Client) GetChallenge(ctx context.Context, url string) (*Challenge, erro
//
// The server will then perform the validation asynchronously.
func (c *Client) Accept(ctx context.Context, chal *Challenge) (*Challenge, error) {
return c.AcceptWithPayload(ctx, chal, []byte("{}"))
}

// AcceptWithPayload is a low-level Accept that informs the server that
// the client accepts one of its challenges previously obtained with c.Authorize,
// using a user-defined payload sent in the request. This allows the server and client
// to agree on a custom challenge/response mechanism that supports both asynchronous
// and synchronous resolution schemes.
func (c *Client) AcceptWithPayload(ctx context.Context, chal *Challenge, payload []byte) (*Challenge, error) {
if _, err := c.Discover(ctx); err != nil {
return nil, err
}

payload := json.RawMessage("{}")
if len(chal.Payload) != 0 {
payload = chal.Payload
}
res, err := c.post(ctx, nil, chal.URI, payload, wantStatus(
res, err := c.post(ctx, nil, chal.URI, json.RawMessage(payload), wantStatus(
http.StatusOK, // according to the spec
http.StatusAccepted, // Let's Encrypt: see https://goo.gl/WsJ7VT (acme-divergences.md)
))
Expand Down