我无法在带有SELinux的CentOS服务器上启动Apache。错误日志给出了。
[root@server httpd]# cat test-error_log
[Wed Nov 15 05:42:34 2017] [error] Init: Private key not found
[Wed Nov 15 05:42:34 2017] [error] SSL Library Error: 218529960 error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag
[Wed Nov 15 05:42:34 2017] [error] SSL Library Error: 218640442 error:0D08303A:asn1 encoding routines:ASN1_TEMPLATE_NOEXP_D2I:nested asn1 error
[Wed Nov 15 05:42:34 2017] [error] SSL Library Error: 218529960 error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag
[Wed Nov 15 05:42:34 2017] [error] SSL Library Error: 218595386 error:0D07803A:asn1 encoding routines:ASN1_ITEM_EX_D2I:nested asn1 error
[Wed Nov 15 05:42:34 2017] [error] SSL Library Error: 67710980 error:04093004:rsa routines:OLD_RSA_PRIV_DECODE:RSA lib
[Wed Nov 15 05:42:34 2017] [error] SSL Library Error: 218529960 error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag
[Wed Nov 15 05:42:34 2017] [error] SSL Library Error: 218595386 error:0D07803A:asn1 encoding routines:ASN1_ITEM_EX_D2I:nested asn1 error
这里也失败了
[root@server private]# openssl rsa -in test.key -check -noout
unable to load Private Key
140598241089352:error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag:tasn_dec.c:1319:
140598241089352:error:0D07803A:asn1 encoding routines:ASN1_ITEM_EX_D2I:nested asn1 error:tasn_dec.c:381:Type=RSA
140598241089352:error:04093004:rsa routines:OLD_RSA_PRIV_DECODE:RSA lib:rsa_ameth.c:115:
140598241089352:error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag:tasn_dec.c:1319:
140598241089352:error:0D07803A:asn1 encoding routines:ASN1_ITEM_EX_D2I:nested asn1 error:tasn_dec.c:381:Type=PKCS8_PRIV_KEY_INFO
140598241089352:error:0907B00D:PEM routines:PEM_READ_BIO_PRIVATEKEY:ASN1 lib:pem_pkey.c:132:
路径位于conf文件中
[root@server conf]# cat /etc/httpd/conf.d/test.conf
<VirtualHost *:443>
ServerAdmin webmaster@server.com
DocumentRoot /var/www/html/test
ServerName server.server.com
SSLEngine on
SSLProtocol all -SSLv2 -SSLv3
SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW
SSLCertificateFile /etc/pki/tls/certs/test.crt
SSLCertificateKeyFile /etc/pki/tls/private/test.key
ErrorLog logs/test-error_log
CustomLog logs/test-access_log common
我还检查了私钥中没有空格。这是出错的其他想法吗?
另外
[root@server etc]# ls -dZ /etc/pki/tls/private/
drwxr-xr-x. root root system_u:object_r:httpd_sys_content_t:s0 /etc/pki/tls/private/
[root@server etc]# ls -dZ /etc/pki/tls/certs/
drwxr-xr-x. root root system_u:object_r:httpd_sys_content_t:s0 /etc/pki/tls/certs/
我还检查了私钥中没有空格和适当数量的破折号。
编辑:输出ls -al / etc / pki / tls / private /和ls -al / etc / pki / tls / certs /
[root@server ~]# ls -al /etc/pki/tls/certs/
total 1788
drwxr-xr-x. 2 root root 4096 Nov 15 08:51 .
drwxr-xr-x. 5 root root 4096 Feb 11 2015 ..
-rw-r--r--. 1 root root 786601 Jul 14 2014 ca-bundle.crt
-rw-r--r--. 1 root root 1005005 Jul 14 2014 ca-bundle.trust.crt
-rw-------. 1 root root 1513 Feb 11 2015 localhost.crt
-rwxr-xr-x. 1 root root 610 Jan 20 2015 make-dummy-cert
-rw-r--r--. 1 root root 2242 Jan 20 2015 Makefile
-rwxr-xr-x. 1 root root 829 Jan 20 2015 renew-dummy-cert
-rw-r--r--. 1 root root 1208 Feb 11 2015 test.crt
-rw-------. 1 root root 3258 Nov 15 08:51 test_1.cert
[root@ip-10-155-16-219 ~]# ls -al /etc/pki/tls/private/
total 16
drwxr-xr-x. 2 root root 4096 Nov 18 21:15 .
drwxr-xr-x. 5 root root 4096 Feb 11 2015 ..
-rw-------. 1 root root 1679 Feb 11 2015 localhost.key
-rw-r--r--. 1 root root 1679 Nov 18 21:15 test.key
[root@server ~]#
答案 0 :(得分:0)
您的私钥是否已加密? 要确定您的私钥是否已加密:
grep ENCRYPTED /etc/pki/tls/private/test.key
如果是,请从私钥中删除密码:
openssl rsa -in /etc/pki/tls/private/test.key -out /etc/pki/tls/private/test-new.key
检查私钥的标题,如下所示:
-----BEGIN RSA PRIVATE KEY-----
检查页脚,应该是这样的:
-----END RSA PRIVATE KEY-----
删除页脚后的所有空格或换行符。
希望这有帮助