httpd返回“SSLCertificateFile:file'/var/iwww/certs/msdfw/c.pem'不存在或为空”

所以最近,我不得不重置我的服务器,因为一些问题和东西。 而现在,我一直在试图重新设置它,而这只是对我而言没有帮助。 我已经成功安装了httpd ,它可以与我的网站一起工作。 但是当我尝试添加一个SSL证书时,CentOS敢于骗我,它不存在。 这里是journalctl -xe的输出。

 Sep 26 17:00:11 localhost systemd[1]: Starting The Apache HTTP Server... -- Subject: Unit httpd.service has begun start-up -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit httpd.service has begun starting up. Sep 26 17:00:11 localhost httpd[5579]: AH00526: Syntax error on line 15 of /etc/httpd/enabled/msdfw.conf: Sep 26 17:00:11 localhost httpd[5579]: SSLCertificateFile: file '/var/iwww/certs/msdfw/c.pem' does not exist or is empty Sep 26 17:00:11 localhost systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE Sep 26 17:00:11 localhost kill[5581]: kill: cannot find process "" Sep 26 17:00:11 localhost systemd[1]: httpd.service: control process exited, code=exited status=1 Sep 26 17:00:11 localhost systemd[1]: Failed to start The Apache HTTP Server. -- Subject: Unit httpd.service has failed -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit httpd.service has failed. -- -- The result is failed. Sep 26 17:00:11 localhost systemd[1]: Unit httpd.service entered failed state. Sep 26 17:00:11 localhost systemd[1]: httpd.service failed. 

我检查过这个文件,它在那里。 我已经尝试给所有权的用户apache ,我已经发酵它分组apache和所有权限更改为777.它没有工作(和恢复权限)。 我试过lsof c.pem ,但没有输出。 这是VirtualHost;

 <VirtualHost *:80> ServerName www.example.com ServerAlias example.com RewriteEngine on RewriteRule ^/?(.*) https://example.com/$1 [R,L] </VirtualHost> <VirtualHost *:443> ServerName example.com DocumentRoot /var/www/msdfw ErrorLog /var/iwww/logs/e-msdfw CustomLog /var/iwww/logs/c-msdfw combined DirectoryIndex index.php SSLEngine on SSLCertificateFile /var/iwww/certs/msdfw/c.pem SSLCertificateKeyFile /var/iwww/certs/msdfw/p.key SSLCertificateChainFile /var/iwww/certs/msdfw/b.pem <Directory /var/www/msdfw/> Require all granted </Directory> </VirtualHost> 

我已经安装mod_ssl所以我不认为就是这样。 我已经做了sudo -u apache cat /var/iwww/certs/msdfw/c.pem来检查它是否可以读取,并且可以。 证书可以被OpenSSL正确parsing。 所以,我不确定问题是什么。 任何人都可以帮忙,请帮忙。 谢谢!

附加信息:

  • 操作系统:CentOS Linux版本7.4.1708
  • 不知道这是什么类别,但最小。

所以…我已经解决了这个问题,但不是完全的。 我试图删除c.pem ,看看它是否仍然识别目录,并给我一些错误,说:

/var/iwww/certs/msdfw/: Is a directory

但事实并非如此。 还是一样的错误。 所以我很笨,放进去;

SSLCertificateFile whoami

是的,我不知道我在想什么。 但是它说/etc/httpd/whoami没有文件,或者是空的。 无论如何,我把它全部移到/etc/httpd/certs/msdfw/并重新configurationVirtualHost。

它的工作…

TL; DR:如果你得到这个,没有别的工作,把它移动到/etc/httpd

看来我错了。 它与标有system_uunconfined_u的证书system_u 。 他们必须被标记为system_u才能被httpd读取。

了解如何在这里更改标签。