camnetdns: use Lets Encrypt http-01 challenge

Fixes #1033

Change-Id: I83b654ee1b33912e92c2b41339dec45de3b13456
This commit is contained in:
mpl 2018-02-21 00:12:10 +01:00
parent 14758c0d1e
commit 86da8c822c
1 changed files with 9 additions and 3 deletions

View File

@ -59,7 +59,7 @@ var launchConfig = &cloudlaunch.Config{
GCEProjectID: GCEProjectID, GCEProjectID: GCEProjectID,
Scopes: []string{ Scopes: []string{
compute.ComputeScope, compute.ComputeScope,
logging.Scope, logging.WriteScope,
datastore.ScopeDatastore, datastore.ScopeDatastore,
}, },
} }
@ -480,6 +480,7 @@ func main() {
tcperr := make(chan error, 1) tcperr := make(chan error, 1)
udperr := make(chan error, 1) udperr := make(chan error, 1)
httpserr := make(chan error, 1)
httperr := make(chan error, 1) httperr := make(chan error, 1)
log.Printf("serving DNS on %s\n", *addr) log.Printf("serving DNS on %s\n", *addr)
go func() { go func() {
@ -501,6 +502,9 @@ func main() {
HostPolicy: autocert.HostWhitelist(hostname), HostPolicy: autocert.HostWhitelist(hostname),
Cache: autocert.DirCache(osutil.DefaultLetsEncryptCache()), Cache: autocert.DirCache(osutil.DefaultLetsEncryptCache()),
} }
go func() {
httperr <- http.ListenAndServe(":http", m.HTTPHandler(nil))
}()
ln, err := tls.Listen("tcp", httpsListenAddr, &tls.Config{ ln, err := tls.Listen("tcp", httpsListenAddr, &tls.Config{
Rand: rand.Reader, Rand: rand.Reader,
Time: time.Now, Time: time.Now,
@ -512,7 +516,7 @@ func main() {
log.Fatalf("Error listening on %v: %v", httpsListenAddr, err) log.Fatalf("Error listening on %v: %v", httpsListenAddr, err)
} }
go func() { go func() {
httperr <- http.Serve(ln, cs) httpserr <- http.Serve(ln, cs)
}() }()
} }
select { select {
@ -520,7 +524,9 @@ func main() {
log.Fatalf("DNS over TCP error: %v", err) log.Fatalf("DNS over TCP error: %v", err)
case err := <-udperr: case err := <-udperr:
log.Fatalf("DNS error: %v", err) log.Fatalf("DNS error: %v", err)
case err := <-httpserr:
log.Fatalf("HTTPS server error: %v", err)
case err := <-httperr: case err := <-httperr:
log.Fatalf("HTTP server error: %v", err) log.Fatalf("HTTP server for Let's Encrypt error: %v", err)
} }
} }