Skip to content

Commit 71d3a4c

Browse files
zhshgopherbot
authored andcommitted
acme: support challenges that require the ACME client to send a non-empty JSON body in a response to the challenge.
A new extension to the ACME protocol is proposed to support device attestation: https://datatracker.ietf.org/doc/draft-acme-device-attest/ Based on the recent IETF meetings, the proposal is likely to be accepted. To support the new extension, the ACME client will need to send a non-empty JSON body in the response to a "device-attest-01" challenge. Fixes golang/go#68674 Change-Id: I29b420ec837f682e3d59071a4a82af56dc319134 Reviewed-on: https://go-review.googlesource.com/c/crypto/+/608975 Reviewed-by: Roland Shoemaker <[email protected]> Reviewed-by: Michael Knyszek <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Auto-Submit: Roland Shoemaker <[email protected]>
1 parent 8929309 commit 71d3a4c

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

acme/acme.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,11 @@ func (c *Client) Accept(ctx context.Context, chal *Challenge) (*Challenge, error
514514
return nil, err
515515
}
516516

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

acme/types.go

+11
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package acme
77
import (
88
"crypto"
99
"crypto/x509"
10+
"encoding/json"
1011
"errors"
1112
"fmt"
1213
"net/http"
@@ -527,6 +528,16 @@ type Challenge struct {
527528
// when this challenge was used.
528529
// The type of a non-nil value is *Error.
529530
Error error
531+
532+
// Payload is the JSON-formatted payload that the client sends
533+
// to the server to indicate it is ready to respond to the challenge.
534+
// When unset, it defaults to an empty JSON object: {}.
535+
// For most challenges, the client must not set Payload,
536+
// see https://tools.ietf.org/html/rfc8555#section-7.5.1.
537+
// Payload is used only for newer challenges (such as "device-attest-01")
538+
// where the client must send additional data for the server to validate
539+
// the challenge.
540+
Payload json.RawMessage
530541
}
531542

532543
// wireChallenge is ACME JSON challenge representation.

0 commit comments

Comments
 (0)