Apache:mod_ssl:错误:未find私钥

我正在安装SSL证书来提供HTTPS。 我在Amazon Linux使用Apache 2.4 ,并在Startssl中获得了证书。 我的Vhostconfiguration如下:

 <IfModule mod_ssl.c> <VirtualHost _default_:443> ServerAdmin [email protected] ServerName myweb.com DocumentRoot /var/www/html/myapp <Directory /var/www/htmlmyapp> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory> ErrorLog /var/log/httpd/error_log LogLevel warn CustomLog /var/log/httpd/ssl_access.log combined SSLEngine on SSLCertificateFile /etc/ssl/certs/mycert.crt SSLCertificateKeyFile /etc/ssl/private/mycert.key SSLCertificateFile /etc/ssl/certs/sub.class1.server.ca.pem BrowserMatch "MSIE [2-6]" \ nokeepalive ssl-unclean-shutdown \ downgrade-1.0 force-response-1. BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown </VirtualHost> </IfModule> 

当我重新启动Apache,我得到这个输出:

 Stopping httpd: [ OK ] Starting httpd: Apache/2.4.12 mod_ssl (Pass Phrase Dialog) Some of your private key files are encrypted for security reasons. In order to read them you have to provide the pass phrases. Private key myweb.com:443:0 (/etc/ssl/private/mycert.key) Enter pass phrase: OK: Pass Phrase Dialog successful. Apache:mod_ssl:Error: Private key not found. **Stopped [FAILED] 

所以,它要求我input一个密钥的密码,密码是好的,然后说它找不到它。 我错过了什么?

在你的configuration中,你有这三行:

 SSLCertificateFile /etc/ssl/certs/mycert.crt SSLCertificateKeyFile /etc/ssl/private/mycert.key SSLCertificateFile /etc/ssl/certs/sub.class1.server.ca.pem 

您正在重复SSLCertificateFile 。 这意味着Apache将使用variables的第二个实例,即/etc/ssl/certs/sub.class1.server.ca.pem – 但是您的密钥是/etc/ssl/certs/mycert.crt ,所以它不符合CA证书。 因此,Apache无法find证书的密钥。

可能你的configuration应该看起来像这样:

 # Server certificate SSLCertificateFile /etc/ssl/certs/mycert.crt # Key to server certificate SSLCertificateKeyFile /etc/ssl/private/mycert.key # Glue certificate to CA SSLCACertificateFile /etc/ssl/certs/sub.class1.server.ca.pem 

请注意,第二个证书以SSLCA而不是仅以SSL开头。

在你的configuration文件中,你指向坏的PrivateKey文件SSLCertificateKeyFile /etc/ssl/private/mycert.key而不是SSLCertificateKeyFile /etc/ssl/private/myweb.key

在这个问题的范围之外:你确定你想保留你的私钥的密码吗? 意味着如果您的服务器重新启动,它将再次需要密码。 但也意味着任何有权访问服务器的人都可能会损害您的私钥。

要生成没有密码的新密钥,请使用: openssl rsa -in oldkey.pem -out newkey.pem