我正在尝试使用acme/autocert在go中设置一个安全的websocket服务器(wss://)。程序启动,但当我尝试连接它时,我得到以下错误:
http: TLS handshake error from <IP>: acme/autocert:
unable to authorize "<my domain>"; challenge "tls-alpn-01" failed with error:
acme: authorization error for <my domain>: 403 urn:acme:error:unauthorized:
Cannot negotiate ALPN protocol "acme-tls/1" for tls-alpn-01 challenge这是我用来启动websocket服务器的代码:
func Run() {
hub = newHub()
go hub.run()
mux := http.NewServeMux()
mux.HandleFunc("/ws", func(w http.ResponseWriter, r *http.Request) {
serveWs(hub, w, r)
})
certManager := autocert.Manager{
Prompt: autocert.AcceptTOS,
Cache: autocert.DirCache("certs"),
}
server := &http.Server{
Addr: ":8080",
Handler: mux,
TLSConfig: &tls.Config{
GetCertificate: certManager.GetCertificate,
},
}
go server.ListenAndServeTLS("", "")
}当缓存(certs文件夹)中没有新证书时,它应该自动获得一个新证书。错误消息告诉我,在创建新证书时协商协议时出现问题。我需要在某个地方添加受支持的协议吗?
发布于 2019-02-04 00:50:07
我不确定您的问题是什么,但我尝试添加HostPolicy,以便让管理器知道允许哪个主机响应。下面是一个示例https://github.com/kjk/go-cookbook/blob/master/free-ssl-certificates/main.go#L77
注意:建议使用443或8443作为安全端口。
https://stackoverflow.com/questions/54504240
复制相似问题