From 76eec36fa14229c4b25bb894c2d0e591527af429 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 27 Sep 2017 13:19:09 -0400 Subject: [PATCH] acme/autocert: add Cache to Manager example If you don't use a cache you're just begging for Let's Encrypt to ban you for a week due to duplicate certificate requests. Don't encourage users to get banned. Change-Id: Icf999c7f28817990bb45931d30692d4040c0ed71 Reviewed-on: https://go-review.googlesource.com/66550 Run-TryBot: Russ Cox TryBot-Result: Gobot Gobot Reviewed-by: Alex Vaghin --- acme/autocert/autocert.go | 6 ++++-- acme/autocert/example_test.go | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/acme/autocert/autocert.go b/acme/autocert/autocert.go index a478eff..b101020 100644 --- a/acme/autocert/autocert.go +++ b/acme/autocert/autocert.go @@ -83,8 +83,10 @@ func defaultHostPolicy(context.Context, string) error { // It obtains and refreshes certificates automatically, // as well as providing them to a TLS server via tls.Config. // -// To preserve issued certificates and improve overall performance, -// use a cache implementation of Cache. For instance, DirCache. +// You must specify a cache implementation, such as DirCache, +// to reuse obtained certificates across program restarts. +// Otherwise your server is very likely to exceed the certificate +// issuer's request rate limits. type Manager struct { // Prompt specifies a callback function to conditionally accept a CA's Terms of Service (TOS). // The registration may require the caller to agree to the CA's TOS. diff --git a/acme/autocert/example_test.go b/acme/autocert/example_test.go index c6267b8..71d61eb 100644 --- a/acme/autocert/example_test.go +++ b/acme/autocert/example_test.go @@ -23,6 +23,7 @@ func ExampleNewListener() { func ExampleManager() { m := autocert.Manager{ + Cache: autocert.DirCache("secret-dir"), Prompt: autocert.AcceptTOS, HostPolicy: autocert.HostWhitelist("example.org"), }