Golang ListenAndServeTLS 的 Letsencrypt 证书输出

Letsencrypt certificate output for golang ListenAndServeTLS

Lets'Encrypt 为我提供了 "Signed Certificate" 和 "Intermediate Certificate"。我之前必须为域创建私钥 domain.key。

现在 ListenAndServeTLS 需要证书和密钥文件。

我猜 "keyfile" 是本地生成的 domain.key 文件,但是如果 ListenAndServeTLS 需要两个文件,我该如何处理 "Signed Certificate" 和 "Intermediate Certificate"?

与大多数 http 服务器一样,Go tls 服务器实现只接受单个文件作为证书。来自 net/http 文档:

If the certificate is signed by a certificate authority, the certFile should be the concatenation of the server's certificate, any intermediates, and the CA's certificate.

您需要做的就是将文件连接在一起。