-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Open
Labels
DocumentationIssues describing a change to documentation.Issues describing a change to documentation.NeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.Feedback is required from experts, contributors, and/or the community before a change can be made.
Milestone
Description
Thanks to @crhym3, we now have a suitably-licensed & CLA-clean ACME implementation in https://godoc.org/golang.org/x/crypto/acme (and a high-level package in https://godoc.org/golang.org/x/crypto/acme/autocert).
I'd like to consider privately vendoring that into Go 1.8 and making HTTPS even easier.
I'd like a complete user program with automatic HTTPS certs to look something like:
package main
import (
"log"
"net/http"
)
func main() {
http.HandleFunc("/", websiteHandler)
srv := &http.Server{
Addr: "example.com:443",
ACMEServer: http.LetsEncrypt, // non-empty enables autocert support
ACMEAgreeTOS: func(tosURL string) bool { return true },
ACMEEmail: "[email protected]", // (but optional)
}
log.Fatal(srv.ListenAndServeTLS("", ""))
}Misc notes:
- The
ACMEFoonames are placeholders. Maybe they'd deserve their own struct. ACMEServerwould be required as the opt-in, and we wouldn't make LetsEncrypt be automatic or preferred, but we would add a constantconst LetsEncrypt = "https://acme-v01.api.letsencrypt.org/directory"like theacmepackage has.ACMEAgreeTOSwould be required for now. The ACME protocol requires a TOS agreement because the CAB Forum requires cert issuers to have a legal relationship with the people getting certs or something. It's mostly a formality, but we shouldn't make it automatically say "yes" either, even though I don't think LetsEncrypt themselves care. Maybe we could export the https://godoc.org/golang.org/x/crypto/acme#AcceptTOS func in thenet/httppackage to reduce the boilerplate.ACMEEmailis optional. If provided, your ACME cert provider can keep you updated on problems or changes.- the default cache directory would be automatic. We could provide a string to let people pick an alternate directory. If you want to do something more complicated (e.g. cache coordination over a cluster), then you can just import the
golang.org/x/crypto/acme/autocertpackage yourself. This is analogous to the HTTP/2 situation where common HTTP/2 is provided automatically, but weird uses require importing the guts. srv.ListenAndServeTLS("", "")is already valid for the past few releases, since 6a208ef for net/http: Server.ListenAndServeTLS not compatible with tls.Config.GetCertificate #14268 requested by @willchan specifically for LetsEncrypt stuff. It's a little ugly but works. Maybe we could provide instead a new method or option which also listens on an cleartext port 80 and redirects HTTP to HTTPS, optionally with a HSTS header.
My goal is for HTTPS to be dead simple out of the box.
Thoughts?
/cc @adg @broady @campoy @quentinmit @rsc @robpike @ianlancetaylor @mholt @crhym3
nhooyr, augustoroman, dsnet, titanous, alex and 161 moredlsniper, tnolli, victorhaggqvist, uluyol, hectorj and 14 morealex, jimmyfrasche, yanpozka, dmitshur, twotwotwo and 20 moremholt, alex, titanous, martingallagher, josharian and 38 more
Metadata
Metadata
Assignees
Labels
DocumentationIssues describing a change to documentation.Issues describing a change to documentation.NeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.Feedback is required from experts, contributors, and/or the community before a change can be made.