php - Apache 2.4.9 在启用 ssl 模块和设置 ssl 证书后失败

标签 php ssl ssl-certificate osx-yosemite apache2.4

Apache 在尝试设置 ssl 证书后抛出以下错误:

[ssl:emerg] [pid 30907] AH02572: Failed to configure at least one certificate and key for localhost:443
[ssl:emerg] [pid 30907] SSL Library Error: error:140A80B1:SSL routines:SSL_CTX_check_private_key:no certificate assigned
[ssl:emerg] [pid 30907] AH02312: Fatal error initialising mod_ssl, exiting.

我使用 MAC 操作系统:优胜美地、PHP 5.5.20、Apache 2.4.9

并已按照这些步骤生成我的 ssl 证书 ( http://www.akadia.com/services/ssh_test_certificate.html )

cd /etc/apache2/
sudo mkdir certs                                        
cd certs                                                
sudo openssl genrsa -des3 -out server.key 1024          
sudo openssl req -new -key server.key -out server.csr

  Country Name (2 letter code) [GB]:US
  State or Province Name (full name) [Berkshire]:California 
  Locality Name (eg, city) [Newbury]:LA
  Organization Name (eg, company) [My Company Ltd]:Company
  Organizational Unit Name (eg, section) []:
  Common Name (eg, your name or your server's hostname) []:dev.test.local
  Email Address []:username@gmail.com
  Please enter the following 'extra' attributes
  to be sent with your certificate request
  A challenge password []:
  An optional company name []:

sudo cp server.key server.key.org     
sudo openssl rsa -in server.key.org -out server.key
sudo openssl x509 -req -days 730 -in server.csr -signkey server.key -out server.crt  

接下来我为我的 apache 配置文件设置了以下内容:

etc/apache2/httpd.conf:

LoadModule ssl_module libexec/apache2/mod_ssl.so
LoadModule socache_shmcb_module libexec/apache2/mod_socache_shmcb.so
Include /private/etc/apache2/extra/httpd-ssl.conf

etc/apache2/extra/httpd-ssl.conf:

Listen 443
SSLPassPhraseDialog  builtin
<VirtualHost _default_:443>
SSLEngine on
Mutex sysvsem default # Added after seeing mutex issues for apache 2.4, http://stackoverflow.com/questions/13969272/apache-sslmutex-issue

etc/apache2/extra/httpd-vhosts.conf:

<VirtualHost *:443>

    ServerName dev.test.local
    DocumentRoot "/Users/username/Sites/test/public"

    <Directory "/Users/username/Sites/test/public">
         Options Indexes FollowSymLinks MultiViews
         AllowOverride All
         Order allow,deny
         allow from all
    </Directory>

    SSLEngine on       
    SSLCertificateFile    /etc/apache2/certs/server.crt
    SSLCertificateKeyFile /etc/apache2/certs/server.key

</VirtualHost>

重新启动并运行 apache config test 后,看起来好像没有问题:

sudo apachectl restart
sudo apachectl configtest
[Tue Jan 06 13:56:01.480270 2015] [so:warn] [pid 31636] AH01574: module php5_module is already loaded, skipping
Syntax OK

非常感谢您的帮助,如果需要,我很乐意提供更多信息。

最佳答案

我遇到了同样的问题。 现在我解决了。

你包括了

/private/etc/apache2/extra/httpd-ssl.conf 

在 httpd.conf 中。

所以你仍然需要在'httpd-ssl.conf'中设置以下键

SSLCertificateFile "path to your crt"
SSLCertificateKeyFile "path to your key"

希望对您有所帮助。

关于php - Apache 2.4.9 在启用 ssl 模块和设置 ssl 证书后失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27807974/

相关文章:

PHP日期6个月以内

php - 如何解决“ fatal error :找不到类'MySQLi'”?

ssl - Heroku + 无法验证 api.heroku.com 的 SSL 证书

c++ - boost .Asio : Writing a SSL Server/Client Too many file types

azure - 无法将 key 值导入应用服务证书

php - 如何将新行的 id 插入到另一个链接表中?

javascript - 在 codeigniter 和 bootstrap 中选择相关服务中获取数据

ssl - 旧客户端的 SSL 证书和具有相同公钥/私钥的新证书

scala - 如何配置 Play 应用程序以使用 Let's Encrypt 证书并转换 Let's Encrypt 证书以便 play 可以理解它?

ssl - 自签名证书和根 CA 证书是否相同?