apache的https 证书给golang用,提示错误 :(

申请了经过认证的ssl证书,有1_root_bundle.crt2_your_domain .crt、两个文件,还有mydomain_private.key

SSLCertificateFile "/usr/local/apache2/conf/2_your_domain.crt"
SSLCertificateKeyFile "/usr/local/apache2/conf/mydomain_private.key"
SSLCertificateChainFile "/usr/local/apache2/conf/1_root_bundle.crt"

apache会安装,
golang中cat 1_root_bundle.crt 2_your_domain.crt >server.crt

golang 中这行代码是

http.ListenAndServeTLS(":8081", "server.crt", "mydomain_private.crt", nil)

但提示错误

2017/02/17 21:43:05 ListenAndServe: tls: failed to find PEM block with type ending in "PRIVATE KEY" in key input after skipping PEM blocks of the following types: [CERTIFICATE CERTIFICATE CERTIFICATE]

请问,这种情况怎么解决啊?

共 3 个回复


czxichen

用法有问题,应该是用,crt.key做服务端监听,root crt是给客户端用的,

# 0

fanyang

mydomain_private.crt 存在这个文件?

# 1

joe9i0

你第三个参数名称错了, 应该是mydomain_private.key, 而不是mydomain_private.crt

# 2