Hello,
I have a very stupid problem with autocert. The below code works:
log.Println("sslHosts:", sslHosts)
log.Println("sslCertDir:", sslCertDir)
certManager := autocert.Manager{
Prompt: autocert.AcceptTOS,
HostPolicy: autocert.HostWhitelist(strings.Split(sslHosts, " ")...),
Cache: autocert.DirCache(sslCertDir),
}
go func() {
log.Fatal(http.ListenAndServe(":http", certManager.HTTPHandler(nil)))
}()
// go log.Fatal(http.ListenAndServe(":http", certManager.HTTPHandler(nil)))
s.Addr = ":https"
s.TLSConfig = certManager.TLSConfig()
log.Fatal(s.ListenAndServeTLS("", ""))
Once I remove the go func() and uncomment the // go log line, the server no
longer serves HTTPS requests while HTTP continues to work.
I'm totally stumped- the two go funcs should imho be equivalent? Any
insight what's wrong here would be highly appreciated.
I'm using go 1.16.3-arm64 on Darwin, cross-compiled to amd64.
Cheers,
Andi
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/3b9683bc-3bd6-4a43-b82e-0f4834419a32n%40googlegroups.com.