From 32e80eca20a3f4eed527d2ff089150d34b301a3e Mon Sep 17 00:00:00 2001 From: jhernandezb Date: Fri, 12 Jan 2018 22:54:49 -0600 Subject: [PATCH] lets encrypt: migrate to http-01 challenge --- cmd/drone-server/server.go | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/cmd/drone-server/server.go b/cmd/drone-server/server.go index 89f938abd..a90877900 100644 --- a/cmd/drone-server/server.go +++ b/cmd/drone-server/server.go @@ -576,24 +576,23 @@ func server(c *cli.Context) error { // start the server with lets encrypt enabled // listen on ports 443 and 80 + address, err := url.Parse(c.String("server-host")) + if err != nil { + return err + } + + dir := cacheDir() + os.MkdirAll(dir, 0700) + + manager := autocert.Manager{ + Prompt: autocert.AcceptTOS, + HostPolicy: autocert.HostWhitelist(address.Host), + Cache: autocert.DirCache(dir), + } g.Go(func() error { - return http.ListenAndServe(":http", http.HandlerFunc(redirect)) + return http.ListenAndServe(":http", manager.HTTPHandler(http.HandlerFunc(redirect))) }) - g.Go(func() error { - address, err := url.Parse(c.String("server-host")) - if err != nil { - return err - } - - dir := cacheDir() - os.MkdirAll(dir, 0700) - - manager := autocert.Manager{ - Prompt: autocert.AcceptTOS, - HostPolicy: autocert.HostWhitelist(address.Host), - Cache: autocert.DirCache(dir), - } serve := &http.Server{ Addr: ":https", Handler: handler,