Skip to content

Commit a408498

Browse files
committed
acme: only require prompt if server has terms of service
Fixes golang/go#64881 Change-Id: I2b4415e6f987aab258c26c090ac7b1a465aa1697 Reviewed-on: https://go-review.googlesource.com/c/crypto/+/719001 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Junyang Shao <shaojunyang@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Filippo Valsorda <filippo@golang.org>
1 parent cab0f71 commit a408498

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

acme/autocert/autocert.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,6 @@ func (m *Manager) TLSConfig() *tls.Config {
248248
// If GetCertificate is used directly, instead of via Manager.TLSConfig, package users will
249249
// also have to add acme.ALPNProto to NextProtos for tls-alpn-01, or use HTTPHandler for http-01.
250250
func (m *Manager) GetCertificate(hello *tls.ClientHelloInfo) (*tls.Certificate, error) {
251-
if m.Prompt == nil {
252-
return nil, errors.New("acme/autocert: Manager.Prompt not set")
253-
}
254-
255251
name := hello.ServerName
256252
if name == "" {
257253
return nil, errors.New("acme/autocert: missing server name")

acme/autocert/autocert_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ func TestGetCertificate(t *testing.T) {
201201
prepare: func(t *testing.T, man *Manager, s *acmetest.CAServer) {
202202
man.Prompt = nil
203203
},
204-
expectError: "Manager.Prompt not set",
204+
expectError: "missing Manager.Prompt",
205205
},
206206
{
207207
name: "trailingDot",

acme/autocert/internal/acmetest/ca.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,8 @@ type discovery struct {
239239
}
240240

241241
type discoveryMeta struct {
242-
ExternalAccountRequired bool `json:"externalAccountRequired,omitempty"`
242+
Terms string `json:"termsOfService,omitempty"`
243+
ExternalAccountRequired bool `json:"externalAccountRequired,omitempty"`
243244
}
244245

245246
type challenge struct {
@@ -281,6 +282,7 @@ func (ca *CAServer) handle(w http.ResponseWriter, r *http.Request) {
281282
NewAccount: ca.serverURL("/new-account"),
282283
NewOrder: ca.serverURL("/new-order"),
283284
Meta: discoveryMeta{
285+
Terms: ca.serverURL("/terms"),
284286
ExternalAccountRequired: ca.eabRequired,
285287
},
286288
}

acme/rfc8555.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ func (c *Client) registerRFC(ctx context.Context, acct *Account, prompt func(tos
5353
Contact: acct.Contact,
5454
}
5555
if c.dir.Terms != "" {
56+
if prompt == nil {
57+
return nil, errors.New("acme: missing Manager.Prompt to accept server's terms of service")
58+
}
5659
req.TermsAgreed = prompt(c.dir.Terms)
5760
}
5861

0 commit comments

Comments
 (0)