apache - 安装了自签名 SSL 证书,Apache 无法启动

标签 apache ssl https xampp self-signed

我正在尝试建立一个需要 Stripe 支付网关的网站,因此需要 SSL。我在 Windows 10 上使用 XAMPP。生成 SSL 证书和 key 对并在 Apache 中安装后,Apache 不再启动。

我附上了一些错误消息和配置。请帮忙。

这是 Apache 错误日志中的消息。它不再重现这些错误消息。所以一定有什么改变了。我想我尝试通过不同的方法生成证书和 key 。但是 Apache 仍然无法启动。

[Sun Feb 19 15:45:25.312250 2017] [ssl:emerg] [pid 6508:tid 556] AH02577: Init: SSLPassPhraseDialog builtin is not supported on Win32 (key file C:/xampp/apache/conf/ssl.key/server.key)
[Sun Feb 19 15:45:25.312250 2017] [ssl:emerg] [pid 6508:tid 556] AH02311: Fatal error initialising mod_ssl, exiting. See C:/xampp/apache/logs/error.log for more information
[Sun Feb 19 15:45:25.312250 2017] [ssl:emerg] [pid 6508:tid 556] AH02564: Failed to configure encrypted (?) private key www.loc1.dev:443:0, check C:/xampp/apache/conf/ssl.key/server.key
[Sun Feb 19 15:45:25.312250 2017] [ssl:emerg] [pid 6508:tid 556] SSL Library Error: error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag
[Sun Feb 19 15:45:25.312250 2017] [ssl:emerg] [pid 6508:tid 556] SSL Library Error: error:0D08303A:asn1 encoding routines:ASN1_TEMPLATE_NOEXP_D2I:nested asn1 error
[Sun Feb 19 15:45:25.312250 2017] [ssl:emerg] [pid 6508:tid 556] SSL Library Error: error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag
[Sun Feb 19 15:45:25.312250 2017] [ssl:emerg] [pid 6508:tid 556] SSL Library Error: error:0D07803A:asn1 encoding routines:ASN1_ITEM_EX_D2I:nested asn1 error (Type=RSA)
[Sun Feb 19 15:45:25.312250 2017] [ssl:emerg] [pid 6508:tid 556] SSL Library Error: error:04093004:rsa routines:OLD_RSA_PRIV_DECODE:RSA lib
[Sun Feb 19 15:45:25.312250 2017] [ssl:emerg] [pid 6508:tid 556] SSL Library Error: error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag
[Sun Feb 19 15:45:25.312250 2017] [ssl:emerg] [pid 6508:tid 556] SSL Library Error: error:0D07803A:asn1 encoding routines:ASN1_ITEM_EX_D2I:nested asn1 error (Type=PKCS8_PRIV_KEY_INFO)
AH00016: Configuration Failed

这是我尝试从命令行启动 Apache 时遇到的错误。

Apache 2 is starting ...
AH00548: NameVirtualHost has no effect and will be removed in the next release C:/xampp/apache/conf/extra/httpd-vhosts.conf:26
(OS 10048)Only one usage of each socket address (protocol/network address/port) is normally permitted.  : AH00072: make_sock: could not bind to address [::]:443
(OS 10048)Only one usage of each socket address (protocol/network address/port) is normally permitted.  : AH00072: make_sock: could not bind to address 0.0.0.0:443
AH00451: no listening sockets available, shutting down
AH00015: Unable to open logs

这是在 XAMPP 控制对话框中发布的错误。

1:16:13 PM  [Apache]    Error: Apache shutdown unexpectedly.
1:16:13 PM  [Apache]    This may be due to a blocked port, missing dependencies, 
1:16:13 PM  [Apache]    improper privileges, a crash, or a shutdown by another method.
1:16:13 PM  [Apache]    Press the Logs button to view error logs and check
1:16:13 PM  [Apache]    the Windows Event Viewer for more clues
1:16:13 PM  [Apache]    If you need more help, copy and post this
1:16:13 PM  [Apache]    entire log window on the forums

这是 httpd-vhosts.conf 中的内容。我正在尝试为 loc1.dev 设置 SSL。

<VirtualHost *:80>
  DocumentRoot "C:/xampp/htdocs"
  ServerName localhost
</VirtualHost>

<VirtualHost *:80>
  DocumentRoot "C:/xampp/htdocs/loc.com/public_html"
  ServerName loc.dev
  ServerAlias www.loc.dev
  <Directory "C:/xampp/htdocs/loc.com/public_html">
  AllowOverride All
  Require all Granted
  </Directory>
</VirtualHost>

<VirtualHost *:80>
  DocumentRoot "C:/xampp/htdocs/loc1.com/public_html"
  ServerName loc1.dev
  ServerAlias www.loc1.dev
  <Directory "C:/xampp/htdocs/loc1.com/public_html">
  AllowOverride All
  Require all Granted
  </Directory>
</VirtualHost>

<VirtualHost *:80>
  DocumentRoot "C:/xampp/htdocs/foodharbor.org/public_html"
  ServerName foodharbor.dev
  ServerAlias www.foodharbor.dev
  <Directory "C:/xampp/htdocs/foodharbor.org/public_html">
  AllowOverride All
  Require all Granted
  </Directory>
</VirtualHost>

这是我在 httpd-ssl.conf 中的内容

<VirtualHost _default_:443>

#   General setup for the virtual host
DocumentRoot "C:/xampp/htdocs/loc1.com/public_html"
ServerName www.loc1.dev
ServerAdmin jonathan.najman@gmail.com
ErrorLog "C:/xampp/apache/logs/error.log"
TransferLog "C:/xampp/apache/logs/access.log"
SSLEngine on
SSLCertificateFile "conf/ssl.crt/server.crt"
SSLCertificateKeyFile "conf/ssl.key/server.key"

</VirtualHost>     

这是我的主机文件 (C:\Windows\System32\drivers\etc\hosts) 中的内容。

127.0.0.1   localhost
127.0.0.1   loc.dev
127.0.0.1   loc1.dev
127.0.0.1   foodharbor.dev

我错过了什么吗?

最佳答案

我在 httpd-ssl.conf (C:\xampp\apache\conf\extra) 中注释掉了 Listen 443,现在 Apache 启动了,站点在 https 和 http 上可用。肯定已经有其他地方的指令指示 Apache 监听 443 ...

#
# When we also provide SSL we have to listen to the 
# standard HTTP port (see above) and to the HTTPS port
#
#Listen 443

关于apache - 安装了自签名 SSL 证书,Apache 无法启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42355178/

相关文章:

ruby - 加密空字符串

magento - 如何在 Mgt 开发环境中使用带有自签名证书的 HTTPS/SSL

asp.net-mvc - ASP.NET MVC : How to disable SSL 2. 0

SSL 客户端 (soapUI) 未使用证书响应服务器 CertificateRequest

java - 运行 HTTPS 服务器时出现问题

java - 如何从 Java 应用程序获取远程 HTTPS 服务器支持的密码列表?

php - LAMP 中的 XAMPP 和 WAMP,哪个最好?

apache - 不同的 .htaccess 重写规则取决于 $_GET 参数

java - CXF Web 客户端中的动态查询参数

apache - 无效命令 'RedirectMatch' - Apache 2.47。 Ubuntu 信任