apache - 无法在未找到 CentOS 私钥上启动 Apache

标签 apache ssl centos private-key

我无法使用 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 ~]#

最佳答案

你的私钥加密了吗? 要确定您的私钥是否已加密:

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

删除页脚后的所有空格或换行符。

希望对你有帮助

关于apache - 无法在未找到 CentOS 私钥上启动 Apache,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47306335/

相关文章:

php - Azure App Service 中的 Wordpress 无法通过符号链接(symbolic link)读取文件

java - 如何配置Tomcat6以监听2个IP(实际和虚拟)

php - 用于保护 LDAP 服务器的 ldap_bind 返回 "Unknown CA"

ssl - aws 连接上的 OpenSSL 未知协议(protocol)错误

linux - mod_rewrite REQUEST_URI 混淆

security - 在线支付需要哪些安全措施?

java.io.IOException : Cannot run program "/bin/bash": error=24, 打开文件太多

centos - Centos7 上的 DHCP 错误

apache - 如何停止重写规则?

php - 使用 .htaccess 重定向一个类别并将其发布到一个新的 URL