大网数据广告活动
服务器运维问答

Install SSL certificate on Apache Windows Server 2012 R2

· 52CE 我爱测

I am a developer. Our server admins have given me 3 files. .cer, .pfx and .p7b and told me to install SSL in Apache Server. I have Wamp with Apache version 2.4.9. I have search and found something. I open httpd.conf file and sear…

问题原文

原帖链接 · Imran Qadir Baksh - Baloch · CC BY-SA 3.0

I am a developer. Our server admins have given me 3 files. .cer, .pfx and .p7b and told me to install SSL in Apache Server. I have Wamp with Apache version 2.4.9. I have search and found something. I open httpd.conf file and search for DocumentRoot. After DocumentRoot I have added,

DocumentRoot "c:/wamp/www/"

SSLEngine on

SSLCertificateFile C:/Path/MyCer.cer

SSLCertificateKeyFile C:/Path/MyPfx.pfx

SSLCACertificateFile C:/Path/MyP7b.p7b

Now when I restart the apache. I am unable to navigate the server even on http. When I comment the above lines, my sites works on http.

已采纳解答

原帖链接 · Miguel Caldas · CC BY-SA 3.0

Although this is not exactly a "question", and you do not specify what is inside your files, you're doing at least one thing wrong: a pfx file (assuming this is not a naming error) cannot be used directly as a "key" in Apache. Without knowing the contents of the cer and the p7b file, let's assume that the pfx has all the info we need and that you have the pfx password (you do, right?), and start from there.

  1. Grab and install OpenSSL for Windows (Suggestion: https://indy.fulgan.com/SSL/ has precompiled binaries if you're not willing to build from sources in http://www.openssl.org/)

  2. Extract the different files required for Apache from the pfx (you'll be prompted for the pfx password when required):

    a. Extract the SSL Certificate Private Key (Encrypted) from the pfx

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

    b. Remove the encryption from the SSL Certificate Private Key

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

    c. Extract SSL Certificate from the pfx

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

    d. Extract the (possibly empty) CA Certificate Chain from the pfx

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

  3. Rebuild your httpd.conf using these lines instead of yours (note: ONLY INCLUDE THE SSLCACertificateFile line if the MyCAs.crt is not empty; you can check it with any text editor)

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

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-04-04)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。