Apache 启动失败,ssl 问题

Apache 启动失败,ssl 问题

由于某种原因,Apache 无法启动。我尝试重新启动服务器,但无济于事。现在是凌晨 2 点左右,我的大脑已经崩溃。这是 Apache 日志。我没有触碰任何配置、证书或密钥来导致这种情况,所以我不知道发生了什么。这里有第一行,但这是假的,但密钥就在我指定要查看的虚拟主机文件的确切位置。

[Wed Mar 04 00:13:51.898515 2015] [ssl:error] [pid 4307] AH02203: Init: Private key not     found
[Wed Mar 04 00:13:51.899365 2015] [ssl:error] [pid 4307] SSL Library Error: error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag
[Wed Mar 04 00:13:51.899381 2015] [ssl:error] [pid 4307] SSL Library Error: error:0D08303A:asn1 encoding routines:ASN1_TEMPLATE_NOEXP_D2I:nested asn1 error
[Wed Mar 04 00:13:51.899391 2015] [ssl:error] [pid 4307] SSL Library Error: error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag
[Wed Mar 04 00:13:51.899402 2015] [ssl:error] [pid 4307] SSL Library Error: error:0D07803A:asn1 encoding routines:ASN1_ITEM_EX_D2I:nested asn1 error (Type=RSA)
[Wed Mar 04 00:13:51.899413 2015] [ssl:error] [pid 4307] SSL Library Error: error:04093004:rsa routines:OLD_RSA_PRIV_DECODE:RSA lib
[Wed Mar 04 00:13:51.899422 2015] [ssl:error] [pid 4307] SSL Library Error: error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag
[Wed Mar 04 00:13:51.899432 2015] [ssl:error] [pid 4307] SSL Library Error: error:0D07803A:asn1 encoding routines:ASN1_ITEM_EX_D2I:nested asn1 error (Type=PKCS8_PRIV_KEY_INFO)

虚拟主机:

# Optionally load the headers module:
#LoadModule headers_module modules/mod_headers.so

LoadModule ssl_module /usr/lib/apache2/modules/mod_ssl.so
SSLCertificateFile /etc/ssl/certs/foobar.org.ssl.crt
SSLCertificateKeyFile /etc/ssl/private/foobar.org.ssl.key
SSLCertificateChainFile /etc/ssl/certs/sub.class1.server.ca.pem
SSLCACertificateFile /etc/ssl/certs/ca.pem
SSLCompression Off
SSLHonorCipherOrder On
SSLSessionCache shmcb:/etc/apache2/logs/ssl_gcache_data(512000)
SSLCipherSuite ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS:!AES256
SSLUseStapling on
SSLStaplingCache "shmcb:logs/stapling-cache(150000)"
SSLSessionCacheTimeout  300

<VirtualHost *:443>
ServerAdmin [email protected]
ServerName foobar.org
#  ServerAlias foobar.org
DirectoryIndex index.html index.php
DocumentRoot /var/www/foobar.org/public_html/
LogLevel warn
ErrorDocument 404 /404.php
#  ErrorDocument 500 /500.html
ErrorLog /var/www/foobar.org/log/error.log
CustomLog /var/www/foobar.org/log/access.log combined
SSLEngine on
SSLProtocol all -SSLv2 -SSLv3
Header always set Strict-Transport-Security "max-age=15768000;includeSubDomains"
</VirtualHost>

ls 命令输出:

-rw-rw-r-- 1 brandon brandon  1767 Mar  4 00:02 foobar.org.ssl.key
-rw-r----- 1 root    ssl-cert 1704 Apr 20  2013 ssl-cert-snakeoil.key

答案1

这里有几个关键问题。Apache 发出的错误告诉您私钥无法解析为有效的 ASN.1。这表明您在密钥中的某个地方有多余的数据,例如空格。其次,您的权限太宽松了。私钥应该由 root 拥有,并且具有类似于 640 或 -rw-r---- 的权限。

答案2

你可能在传输过程中更改了密钥文件的编码

rm /etc/pki/tls/certs/your_server.key 
cp /your_server.key /etc/pki/tls/certs/

service httpd start

答案3

您必须通过命令 chmod 600 ssl.key 为您的 SSL 密钥文件授予 600 权限。有时由于安全策略而发生这种情况。更改权限并启动 Apache 服务后,它就会正常工作。

相关内容