acme:<domain> (acme/autocert) 的授权错误
acme: authorization error for <domain> (acme/autocert)
当运行以下代码时我得到错误:
acme: authorization error for domain (where domain is replaced by my
actual domain)
还有其他人遇到过这个问题吗?返回的错误并没有提供太多信息。
package main
import (
"crypto/tls"
"net/http"
"golang.org/x/crypto/acme/autocert"
)
func main() {
certManager := autocert.Manager{
Prompt: autocert.AcceptTOS,
HostPolicy: autocert.HostWhitelist(<domain>), //your domain here
Cache: autocert.DirCache("cache"), //folder for storing certificates
}
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Hello world"))
})
server := &http.Server{
Addr: ":8086",
TLSConfig: &tls.Config{
GetCertificate: certManager.GetCertificate,
}
if err := server.ListenAndServeTLS("", ""); err != nil {
print(err.Error())
}
}
也许您的服务器在端口 8086 上,而 tls 挑战在端口 443 上?
尝试在端口 443 上提供服务(您可能必须设置二进制文件以允许它执行此操作)。
在让加密上看到这个问题:
当运行以下代码时我得到错误:
acme: authorization error for domain (where domain is replaced by my actual domain)
还有其他人遇到过这个问题吗?返回的错误并没有提供太多信息。
package main
import (
"crypto/tls"
"net/http"
"golang.org/x/crypto/acme/autocert"
)
func main() {
certManager := autocert.Manager{
Prompt: autocert.AcceptTOS,
HostPolicy: autocert.HostWhitelist(<domain>), //your domain here
Cache: autocert.DirCache("cache"), //folder for storing certificates
}
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Hello world"))
})
server := &http.Server{
Addr: ":8086",
TLSConfig: &tls.Config{
GetCertificate: certManager.GetCertificate,
}
if err := server.ListenAndServeTLS("", ""); err != nil {
print(err.Error())
}
}
也许您的服务器在端口 8086 上,而 tls 挑战在端口 443 上? 尝试在端口 443 上提供服务(您可能必须设置二进制文件以允许它执行此操作)。
在让加密上看到这个问题: