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

我剛剛評論了他們,現在它正在工作。我不知道為什麼,但科學是基於證據的。

相關內容