我正在尝试安装SSL证书,并且出现以下错误:
AH02241: Init: Unable to read server certificate from file /path/my.crt SSL Library Error: error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag SSL Library Error: error:0D07803A:asn1 encoding routines:ASN1_ITEM_EX_D2I:nested asn1 error (Type=X509) AH02312: Fatal error initialising mod_ssl, exiting.
以下是我遵循的过程:
我生成了我的私钥:
openssl genrsa -out my.key 2048
我创build了CSR:
openssl req -new -key my.key -out my.csr
我把CSR提供给了IT部门,他们回来了一个crt – 开头
-----BEGIN CERTIFICATE-----
我的ssl.conf(my.example.com与在生成CSR期间使用的通用名称相匹配):
<VirtualHost my.example.com:443> SSLEngine On ServerName my.example.com SSLCertificateFile /path/my.crt SSLCertificateKeyFile /path/my.key </VirtualHost>
我没有SSLCertificateChainFile或SSLCACertificate文件集。
私钥开始
----BEGIN RSA PRIVATE KEY-----
csr开始
-----BEGIN CERTIFICATE REQUEST-----
我已经证实,两者:
openssl rsa -noout -modulus -in my.key openssl req -noout -modulus -in my.csr
产生相同的输出。 我无法弄清楚如何validationcrt – 尝试x509和rsa都会产生错误。
这个过程是否有效? 我可以validationmy.crt以某种方式匹配密钥吗?
事实certificate,我提供的证书是不好的。
运行
openssl x509 -in my.crt -text
应该已经工作了,但是由于证书是腐败的,所以产生了错误:
unable to load certificate 140513785948000:error:0D07209B:asn1 encoding routines:ASN1_get_object:too long:asn1_lib.c:142: 140513785948000:error:0D068066:asn1 encoding routines:ASN1_CHECK_TLEN:bad object header:tasn_dec.c:1306: 140513785948000:error:0D07803A:asn1 encoding routines:ASN1_ITEM_EX_D2I:nested asn1 error:tasn_dec.c:381:Type=X509 140513785948000:error:0906700D:PEM routines:PEM_ASN1_read_bio:ASN1 lib:pem_oth.c:83:
我想我应该注意到,在查看坏证书时,块中的行不完全相同。
对于:
SSLCertificateFile my.crt SSLCertificateKeyFile my.key
您应该使用这些文件的完整path,即:
SSLCertificateFile /home/vhosts/domain.com/keys/my.crt SSLCertificateKeyFile /home/vhosts/domain.com/keys/my.crt
更新正确的path并重新启动Apache以应用更改。 如果问题仍然存在,请发回更新的错误/消息。
-Brendan
只是为了logging:我有同样的错误报告,问题不在证书中,而是在configuration中。
我错误地将密钥定义为证书,将证书定义为密钥。 结果是相同的错误信息。
错误是由于我的参考configuration以相反的顺序呈现这些项目。
即使是@Brendan的例子也有这个错误,因为它引用了两次证书 – 证书和密钥。
所以一定要检查你在正确的参数中引用了正确的文件。