SSLEngine 开启时 Apache 无法启动

SSLEngine 开启时 Apache 无法启动

我的 SSL 虚拟主机就是这么简单:

LoadModule ssl_module modules/mod_ssl.so

Listen 443
<VirtualHost *:443>
        DocumentRoot "/srv/www/test"
        ServerName <my_website_domain>

        SSLEngine on
        SSLCertificateFile    /etc/ssl/certs/apache-selfsigned.crt
        SSLCertificateKeyFile /etc/ssl/private/apache-selfsigned.key
</VirtualHost>

当我尝试使用以下命令重新启动 Apache 时apache2ctl configtest && systemctl restart apache2

语法 OK
apache2.service 的作业失败,因为控制进程退出并显示错误代码。有关详细信息,请参阅“systemctl status apache2.service”和“journalctl -xe”。

但是当我关闭 SSLEngine 时,SSLEngine offapache 可以正常启动并且正常。

当我systemctl status apache2以 开始后运行时SSLEngine on,我得到:

Syntax OK
● apache2.service - The Apache Webserver
   Loaded: loaded (/usr/lib/systemd/system/apache2.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Fri 2020-08-14 18:06:55 CEST; 1min 9s ago
  Process: 22352 ExecStop=/usr/sbin/start_apache2 -DSYSTEMD -DFOREGROUND -k graceful-stop (code=exited, status=0/SUCCESS)
  Process: 19851 ExecReload=/usr/sbin/start_apache2 -DSYSTEMD -DFOREGROUND -k graceful (code=exited, status=0/SUCCESS)
  Process: 22346 ExecStart=/usr/sbin/start_apache2 -DSYSTEMD -DFOREGROUND -k start (code=exited, status=1/FAILURE)
 Main PID: 22346 (code=exited, status=1/FAILURE)

Aug 14 18:06:55 luu056d start_apache2[22352]: [Fri Aug 14 18:06:55.351148 2020] [so:warn] [pid 22352] AH01574: module authn_core_module is already loaded, skipping
Aug 14 18:06:55 luu056d start_apache2[22352]: [Fri Aug 14 18:06:55.351163 2020] [so:warn] [pid 22352] AH01574: module authz_core_module is already loaded, skipping
Aug 14 18:06:55 luu056d start_apache2[22352]: [Fri Aug 14 18:06:55.351170 2020] [so:warn] [pid 22352] AH01574: module php5_module is already loaded, skipping
Aug 14 18:06:55 luu056d start_apache2[22352]: [Fri Aug 14 18:06:55.351179 2020] [so:warn] [pid 22352] AH01574: module ssl_module is already loaded, skipping
Aug 14 18:06:55 luu056d start_apache2[22352]: [Fri Aug 14 18:06:55.352998 2020] [so:warn] [pid 22352] AH01574: module ssl_module is already loaded, skipping
Aug 14 18:06:55 luu056d start_apache2[22352]: [Fri Aug 14 18:06:55.356261 2020] [core:warn] [pid 22352] AH00117: Ignoring deprecated use of DefaultType in line 143 of /etc/apa.../httpd.conf.
Aug 14 18:06:55 luu056d start_apache2[22352]: httpd (no pid file) not running
Aug 14 18:06:55 luu056d systemd[1]: Failed to start The Apache Webserver.
Aug 14 18:06:55 luu056d systemd[1]: apache2.service: Unit entered failed state.
Aug 14 18:06:55 luu056d systemd[1]: apache2.service: Failed with result 'exit-code'.
Hint: Some lines were ellipsized, use -l to show in full.

httpd (no pid file) not running为什么我打开时会出现该错误SSLEngine
没有任何东西阻塞端口 443,因为当我运行lsof -i :443结果为空时。

我在 Linux/SUSE 上使用 Apache/2.4.23

答案1

这表明证书存在问题,httpd 无法加载证书,因此无法正常启动。通常,除非您对 SSL 的错误日志记录级别较高,否则不会显示这些错误。只需设置LogLevel ssl:trace8进行测试,然后在工作时将其删除。

确保证书是 PEM 格式(ASCII),它们彼此匹配并且存在于您指向它们的路径中:

openssl x509 -in /etc/ssl/certs/apache-selfsigned.crt -noout -modulus
openssl rsa -in /etc/ssl/private/apache-selfsigned.key -noout -modulus

两个命令的输出应该返回相同的结果,如果不是,则它们不正确。

答案2

我想感谢所有其他回复的人,但问题出在文件中ssl-globals.conf

这两个指令导致 Apache 崩溃

SSLUseStapling on
SSLStaplingCache "shmcb:logs/stapling-cache(150000)"

我刚刚评论了它们,现在它起作用了。我不知道为什么,但科学是基于证据的。

相关内容