在 Apache Windows Server 2012 R2 上安装 SSL 证书

use*_*567 3 ssl windows-server-2012-r2 apache-2.4

我是一名开发人员。我们的服务器管理员给了我 3 个文件。.cer、.pfx 和 .p7b 并告诉我在 Apache 服务器中安装 SSL。我有 Wamp 和 Apache 版本 2.4.9。我进行了搜索并找到了一些东西。我打开 httpd.conf 文件并搜索 DocumentRoot。在 DocumentRoot 我添加之后,

DocumentRoot "c:/wamp/www/"

SSLEngine on

SSLCertificateFile C:/Path/MyCer.cer

SSLCertificateKeyFile C:/Path/MyPfx.pfx

SSLCACertificateFile C:/Path/MyP7b.p7b
Run Code Online (Sandbox Code Playgroud)

现在当我重新启动 apache 时。即使在 http 上我也无法导航服务器。当我评论以上几行时,我的网站可以在 http 上运行。

Mig*_*das 5

虽然这不完全是一个“问题”,并且您没有指定文件中的内容,但您至少做错了一件事:pfx 文件(假设这不是命名错误)不能直接用作“ Apache 中的密钥”。在不知道 cer 和 p7b 文件内容的情况下,我们假设 pfx 具有我们需要的所有信息,并且您拥有 pfx 密码(您有,对吧?),然后从那里开始。

  1. 获取并安装 OpenSSL for Windows(如果您不愿意从http://www.openssl.org/中的源代码构建,建议:https: //indy.fulgan.com/SSL/已预编译二进制文件)

  2. 从 pfx 中提取 Apache 所需的不同文件(需要时系统会提示您输入 pfx 密码):

    A。从 pfx 中提取 SSL 证书私钥(已加密)

    C:\Path> openssl pkcs12 -in MyPfx.pfx -nocerts -nodes -out MyEncKey.key

    b. 删除 SSL 证书私钥的加密

    C:\Path> openssl rsa -in MyEncKey.key -out MyKey.key

    C。从 pfx 中提取 SSL 证书

    C:\Path> openssl pkcs12 -in MyPfx.pfx -clcerts -nokeys -out MyCert.cer

    d. 从 pfx 中提取(可能为空)CA 证书链

    C:\Path> openssl pkcs12 -in MyPfx.pfx -nodes -nokeys -cacerts -out MyCAs.crt

  3. 使用这些行而不是您的重建 httpd.conf(注意:如果 MyCAs.crt 不为空,则仅包含 SSLCACertificateFile 行;您可以使用任何文本编辑器进行检查)

  SSLCertificateFile C:/Path/MyCert.cer
  SSLCertificateKeyFile C:/Path/MyKey.key
  SSLCACertificateFile C:/Path/MyCAs.crt