geosoft1
(George Calianu)
May 19, 2017, 11:26am
1
I’m experimenting with autocert
. I found something on internet:
package main
import (
"crypto/tls"
"net/http"
"golang.org/x/crypto/acme/autocert"
)
func main() {
m := autocert.Manager{
Prompt: autocert.AcceptTOS,
HostPolicy: autocert.HostWhitelist("localhost"),
Cache: autocert.DirCache("certs"),
}
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Hello world"))
})
s := &http.Server{
Addr: ":https",
TLSConfig: &tls.Config{
GetCertificate: m.GetCertificate,
},
}
s.ListenAndServeTLS("", "")
}
After running as root on Linux (Ubuntu 14.04) i get this error when i access from browser https://:localhost
:
http: TLS handshake error from 127.0.0.1:43018: acme/autocert: server name component count invalid
Any suggestions?
Thanks!
Does your machine have a valid domain name? If so, whitelist this instead of localhost. Letsencrypt cannot issue certificates for localhost .
1 Like
geosoft1
(George Calianu)
May 19, 2017, 1:10pm
3
Now i understand, indeed the machine don’t have a valid domain name. I was playing on my laptop.
geosoft1
(George Calianu)
May 21, 2017, 4:38pm
4
How i resolved, some providers offer DDNS services (mine too ) so i just activated some name on my internet connection and by forwarding 443 port to my laptop ip i was able to run and obtain valid cerificates from Let’s Encrypt. I also replaced autocert.HostWhitelist("localhost")
with autocert.HostWhitelist("mydomainname.com")
. Can be useful when you don’t have a real payed domain name.
1 Like
system
(system)
Closed
August 19, 2017, 4:49pm
5
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.