我尝试从 autocert 文档中运行此示例代码,并将其更改为使用我的域:
package main
import (
"fmt"
"log"
"net/http"
"golang.org/x/crypto/acme/autocert"
)
func main() {
mux := http.NewServeMux()
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello, TLS user! Your config: %+v", r.TLS)
})
log.Fatal(http.Serve(autocert.NewListener("mydomain.work"), mux))
}
在浏览器中,我看到一个 CloudFlare 错误说Error 525 SSL handshake failed. Go 程序的输出是
2020/02/27 00:44:10 http: TLS handshake error from 172.69.22.250:26624: acme/autocert: unable to satisfy "https://acme-v02.api.letsencrypt.org/acme/authz-v3/3031814088" for domain "mydomain.work": no viable challenge type found
当我关闭 CloudFlare 的始终使用 HTTPS 功能时,问题仍然存在,该功能会阻止 http-01 质询。当我在 CloudFlare 控制台中将 TLS 设置为 Off 时,它也仍然存在。我终于回到了 NameCheap 的 Basic DNS 中。
我喜欢 CloudFlare 的功能,所以这让我想知道:如何让 Go 的 autocert 包与 CloudFlare 一起使用?还是没有必要因为我可以使用 CloudFlare 的完全加密设置的自签名证书?
慕少森
相关分类