我尝试从 autocert 文档中运行此示例代码,并将其更改为使用我的域:package mainimport ( "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 的完全加密设置的自签名证书?
1 回答

慕少森
TA贡献2019条经验 获得超9个赞
在 CloudFlare 上,转到 SSL/TLS,然后转到 Origin Server 选项卡。单击“创建证书”按钮,他们会免费为您制作一个。您可以使用它来处理他们的完整(严格)加密设置。
- 1 回答
- 0 关注
- 158 浏览
添加回答
举报
0/150
提交
取消