From 86da8c822cd502f11eedc34db4529f44efaad9aa Mon Sep 17 00:00:00 2001 From: mpl Date: Wed, 21 Feb 2018 00:12:10 +0100 Subject: [PATCH] camnetdns: use Lets Encrypt http-01 challenge Fixes #1033 Change-Id: I83b654ee1b33912e92c2b41339dec45de3b13456 --- server/camnetdns/camnetdns.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/server/camnetdns/camnetdns.go b/server/camnetdns/camnetdns.go index 4e216cf2d..ec1bef4c3 100644 --- a/server/camnetdns/camnetdns.go +++ b/server/camnetdns/camnetdns.go @@ -59,7 +59,7 @@ var launchConfig = &cloudlaunch.Config{ GCEProjectID: GCEProjectID, Scopes: []string{ compute.ComputeScope, - logging.Scope, + logging.WriteScope, datastore.ScopeDatastore, }, } @@ -480,6 +480,7 @@ func main() { tcperr := make(chan error, 1) udperr := make(chan error, 1) + httpserr := make(chan error, 1) httperr := make(chan error, 1) log.Printf("serving DNS on %s\n", *addr) go func() { @@ -501,6 +502,9 @@ func main() { HostPolicy: autocert.HostWhitelist(hostname), Cache: autocert.DirCache(osutil.DefaultLetsEncryptCache()), } + go func() { + httperr <- http.ListenAndServe(":http", m.HTTPHandler(nil)) + }() ln, err := tls.Listen("tcp", httpsListenAddr, &tls.Config{ Rand: rand.Reader, Time: time.Now, @@ -512,7 +516,7 @@ func main() { log.Fatalf("Error listening on %v: %v", httpsListenAddr, err) } go func() { - httperr <- http.Serve(ln, cs) + httpserr <- http.Serve(ln, cs) }() } select { @@ -520,7 +524,9 @@ func main() { log.Fatalf("DNS over TCP error: %v", err) case err := <-udperr: log.Fatalf("DNS error: %v", err) + case err := <-httpserr: + log.Fatalf("HTTPS server error: %v", err) case err := <-httperr: - log.Fatalf("HTTP server error: %v", err) + log.Fatalf("HTTP server for Let's Encrypt error: %v", err) } }