安装 SSL 证书后尝试启动 Apache 时出错

chr*_*ris 6 ssl openssl apache-2.2

我正在尝试安装 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.
Run Code Online (Sandbox Code Playgroud)

这是我遵循的过程:

我生成了我的私钥:

openssl genrsa -out my.key 2048
Run Code Online (Sandbox Code Playgroud)

我用以下方法创建了 CSR:

openssl req -new -key my.key -out my.csr
Run Code Online (Sandbox Code Playgroud)

我向我们的 IT 部门提供了 CSR,他们返回了一个 crt - 它以

-----BEGIN CERTIFICATE-----
Run Code Online (Sandbox Code Playgroud)

我的 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> 
Run Code Online (Sandbox Code Playgroud)

我没有 SSLCertificateChainFile 或 SSLCACertificate 文件集。

私钥以

----BEGIN RSA PRIVATE KEY-----
Run Code Online (Sandbox Code Playgroud)

csr 开始于

-----BEGIN CERTIFICATE REQUEST-----
Run Code Online (Sandbox Code Playgroud)

我已经验证了两者:

openssl rsa -noout -modulus -in my.key
openssl req -noout -modulus -in my.csr 
Run Code Online (Sandbox Code Playgroud)

产生相同的输出。我不知道如何验证 crt - 尝试 x509 和 rsa 都会产生错误。

这个过程应该有效吗?我可以验证 my.crt 以某种方式匹配密钥吗?

chr*_*ris 8

事实证明,我提供的证书很糟糕。

跑步

openssl x509 -in my.crt -text
Run Code Online (Sandbox Code Playgroud)

应该有效,但由于证书已损坏,因此产生了错误:

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:
Run Code Online (Sandbox Code Playgroud)

我想我应该注意到在查看坏证书时块中的行的长度不一样。