通常,我从GoDaddy获得了3个文件:
在配置我的Go服务器中的所有这些文件时,方法如下:
cert, err := tls.LoadX509KeyPair("myalcoholist.pem","myalcoholist.key")
if err != nil {
log.Fatalf("server: loadkeys: %s", err)
}
pem, err := ioutil.ReadFile("cert/sf_bundle-g2-g1.crt")
if err != nil {
log.Fatalf("Failed to read client certificate authority: %v", err)
}
if !certpool.AppendCertsFromPEM(pem) {
log.Fatalf("Can't parse client certificate authority")
}
tlsConfig := &tls.Config{
ClientCAs: certpool,
Certificates: []tls.Certificate{cert},
}
srv := &http.Server{
Addr: "myalcoholist.com:443",
Handler: n,
ReadTimeout: time.Duration(5) * time.Second,
WriteTimeout: time.Duration(5) * time.Second,
TLSConfig: tlsConfig,
}
err := srv.ListenAndServeTLS("cert/myalcoholist.pem","cert/myalcoholist.key")web服务器运行正常,目前在https://myalcoholist.com:443上发布。
我使用https://www.ssllabs.com/ssltest/analyze.html?d=myalcoholist.com验证了我的SSL,它的响应是This server's certificate chain is incomplete. Grade capped to B.
您可以转到此链接查看所有详细结果。
我遗漏了什么?
发布于 2016-07-03 15:28:39
遵循那根线,并从net/http/#ListenAndServeTLS()文档:
如果证书是由证书颁发机构签名的,则certFile应该是服务器的证书、任何中间服务器和CA的证书的连接。
请确保您的cert/myalcoholist.pem也包含CA证书。
该线程使用:
myTLSConfig := &tls.Config{
CipherSuites: []uint16{
tls.TLS_RSA_WITH_RC4_128_SHA,
tls.TLS_ECDHE_RSA_WITH_RC4_128_SHA,
tls.TLS_RSA_WITH_AES_128_CBC_SHA,
tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA},}
myTLSConfig.PreferServerCipherSuites = true
const myWebServerListenAddress = "0.0.0.0:5555"
myTLSWebServer := &http.Server{Addr: myWebServerListenAddress, TLSConfig: myTLSConfig, Handler: router}
if err = myTLSWebServer.ListenAndServeTLS("/home/loongson/webServerKeysV2/golangCertFile2", "/home/loongson/webServerKeysV2/adequatech.ca-comodoinstantssl-exported-privatekey-rsa-ForApache.key"); err != nil {
panic(err)
}与我先前的回答相比,添加密码套件是个好主意,但同样,如果包含CA,请尝试查看传递给ListenAndServeTLS的证书文件是否工作得更好。
果然,https://www.ssllabs.com/ssltest/analyze.html?d=myalcoholist.com报告了A级,并发出警告:“链问题:包含锚”。
请参阅"SSL/TLS:如何修复“链问题:包含锚”“以删除该警告,但不过,这不是错误。
RFC 2119:允许服务器在链中包含根证书(也称为“信任锚”),或者省略它。有些服务器包括它
https://stackoverflow.com/questions/38170775
复制相似问题