4
我正在嘗試配置TLS服務器,以便在連接時返回證書鏈。你如何在Go中建立tls.Certficate鏈?
我想創建一個tls.Config,與證書鏈:
// Certificates contains one or more certificate chains // to present to the other side of the connection. // Server configurations must include at least one certificate // or else set GetCertificate. Certificates []Certificate
假設我的鏈是root -> inter -> server
,我可以獨立加載每個證書,並用一個列表,但只有serverCert被髮送到SSL客戶端。
我做線沿線的東西:
root, err := tls.LoadX509KeyPair("root.crt", "root.key")
inter, err := tls.LoadX509KeyPair("inter.crt", "inter.key")
server, err := tls.LoadX509KeyPair("server.crt", "server.key")
config := tls.Config{
Certificates : []tls.Certificates{root, inter, server}
}
config.BuildNameFromCertificates()
我失去了一些東西明顯?訂單是否重要?
訂單確實重要;試試:'[] tls.Certificates {server,inter,root}'。 –