无法启动Apache,因为找不到CentOS私钥

jgovgodb  于 2022-11-07  发布在  Apache
关注(0)|答案(2)|浏览(211)

我无法在带有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 ~]#
mfpqipee

mfpqipee1#

您的私钥是否加密?要确定您的私钥是否加密:

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-----

删除页脚后的任何空格或换行符。
希望这对你有帮助

9wbgstp7

9wbgstp72#

我也看到人们磅出一行字

#SSL证书文件/etc/pki/tls/证书/本地主机.crt

并且它们用它们的 * 新生成的 * 文件创建一个 * 新 * 行:

SSL证书文件/etc/pki/tls/证书/某些新证书.crt

有趣的事情从这里开始...然后他们将这一行复制到Key文件部分,并执行以下操作:

SSL证书密钥文件/etc/pki/tls/private/本地主机密钥

SSL证书文件/etc/pki/tls/private/某些新密钥。密钥

他们忙碌编辑密钥路径的值,以至于在复制时完全忘记了将SSLCertificateFile更改为SSLCertificateKeyFile。
这种情况经常发生。Apache可能应该改变这些,使它们更不同,这样人们就会注意到这一点,然后再拔出他们的头发调试私钥几个小时,然后才最终弄清楚这一点。

相关问题