指南:WampServer 2.5 中的 Openssl
先决条件:通常不需要安装 openssl(它与 Wamp 捆绑在一起)。例如,Apache 2.4.9 包括 1.0.1g。
系统变量:
- 打开Windows系统面板(“WIN+Q”搜索:系统)>高级系统设置>高级>环境变量
- 在系统变量中添加一个名为 OPENSSL_CONF 的新条目,其值为 openssl.cnf 的路径(通常类似于 C:\wamp\bin\apache\apache2.4.9\conf\openssl.cnf)
openssl 文件夹结构:
配置 openssl.cnf:
- I've followed Neil C. Obremski http://www.neilstuff.com/apache2-ssl-windows.html advice and cleared the following defaults:
- CountryName_default(原为“AU”)
- stateOrProvinceName_default(原为“Some-State”)
- 0.organizationName_default(原为“Internet Widgits Pty Ltd”)
- organizationalUnitName_default(已经为空)
创建证书:
-
从命令行浏览到 C:\wamp\bin\apache\apache#.#.#\bin\ 并调用“openssl req -new -out cacert.csr -keyout cacert.pem”。如果出现提示,请输入密码,然后输入如下所示的 DN 信息。
Loading 'screen' into random state - done
Generating a 1024 bit RSA private key
.......................++++++
....++++++
writing new private key to 'cacert.pem'
Enter PEM pass phrase: my_secret_pass
Verifying - Enter PEM pass phrase: my_secret_pass
`-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
`-----
Country Name (2 letter code) []:
State or Province Name (full name) []:
Locality Name (eg, city) []:
Organization Name (eg, company) []:
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:local
Email Address []:
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
C:\wamp\bin\apache\apache2.4.9\bin>
-
现在在同一个控制台窗口中使用“openssl rsa -in cacert.pem -out cacert.key”,如果要求输入之前输入的密码。
Enter pass phrase for cacert.pem: my_secret_pass
writing RSA key
删除 C:\wamp\bin\apache\apache2.4.9\bin 中的“.rnd”文件
- 仍在同一窗口中调用“openssl x509 -in cacert.csr -out cacert.cert -req -signkey cacert.key -days 365”。如果您遇到以下错误“无法写入‘随机状态’”。这是一个已知的错误 https://stackoverflow.com/a/3058123/999205!要解决此问题,请调用“set RANDFILE=.rnd”并重试上一个命令。
恭喜您现在是自签名证书的所有者!
我已经根据此放置了构建的文件(它们当前位于 bin 文件夹中)Site http://www.phpjoel.com/2011/04/07/installing-ssl-using-openssl-on-a-wamp-localhost/:
- cacert.pem、cacert.key 位于 C:\wamp\bin\apache\apache#.#.#\conf\demoCA\private
- cacert.cert、cacert.csr 位于 C:\wamp\bin\apache\apache#.#.#\conf\demoCA\certs
在 httpd.conf 中启用 SLL(搜索“#Ininclude conf/extra/httpd-ssl.conf”)+更改 httpd-ssl.conf 中的以下条目:
SSLSessionCache "shmcb:C:/wamp/logs/ssl_scache(512000)"
DocumentRoot "C:/wamp/www"
#ErrorLog
#TransferLog
SSLCertificateFile "C:/wamp/bin/apache/apache2.4.9/conf/demoCA/certs/cacert.cert"
SSLCertificateKeyFile "C:/wamp/bin/apache/apache2.4.9/conf/demoCA/private/cacert.key"
CustomLog "C:/wamp/logs/ssl_request.log" \
现在通过调用 httpd -t 测试您的 Apache 安装。
如果您收到以下错误“SSLSessionCache:不支持'shmcb'会话缓存(已知名称:)。也许您需要加载适当的socache模块(mod_socache_shmcb?)。”在 httpd.conf 中启用以下条目“LoadModule socache_shmcb_modulemodules/mod_socache_shmcb.so”
Wamp 现在配置了 https 支持:-)
我还使用 httpd.conf 中的以下配置启用了“LoadModule status_modulemodules/mod_status.so”:
<IfModule status_module>
ExtendedStatus On
<Location /server-status>
SetHandler server-status
</Location>
</IfModule>
您现在可以在这里检查您的服务器状态
https://localhost/server-status/
Apache/2.4.9 (Win64) OpenSSL/1.0.1g PHP/5.5.12 服务器位于本地主机端口 443
Notes:
- 我在尝试让它在我的机器上工作时做了这个教程(这是我第一次尝试在 windows/wamp 上使用 OpenSSL)。
- 本指南不适用于生产系统!
- 您可能需要根据您的 openssl.cnf 更改一些内容,例如名称
- 我的目的不是制作最好的教程,而是简单地记下使 SSL 在 WAMP 中工作所需的所有更改。
- 确保为您的 x509 证书设置正确的天数
- 我终于知道为什么 NSA 可以通过如此复杂的过程轻松侵入服务器了:D
- 由于 Wamp 将 apache 与 OpenSSL 捆绑在一起,因此单独安装它可能会更好?