wamp openssl
2024-10-01 11:36:27
在这一章节里, 我记录了一下如何在 wamp 环境下配置 ssl
前提条件
在设置 Apache + SSL 之前, 需要确认 Apache 已经安装并可以正常工作. 并且 ssl 需要的文件在如下的位置:
1
2
3
4
5
|
[Apache安装目录]/modules/ mod_ssl.so [Apache安装目录]/bin/ openssl.exe, libeay32.dll, ssleay32.dll [Apache安装目录]/conf/ openssl.cnf |
配置文件修改
1
2
3
|
//去掉下面行首的 # 号 #LoadModule ssl_module modules/mod_ssl.so #Include conf/extra/httpd-ssl.conf |
用于载入 ssl 模块和其配置文件
认证文件生成
在命令行下进入Apache安装目录下\bin文件夹,输入命令:
1
2
3
|
//生成证书签发请求 D:\wamp\apache\bin> openssl req - new -out server.csr -config ../conf/openssl.cnf |
1
2
3
4
5
6
7
8
9
10
|
//回车后要求输入密码和确认密码 Loading 'screen' into random state - done Generating a 1024 bit RSA private key ......................................................................++++++ ........................................++++++ writing new private key to 'privkey.pem' Enter PEM pass phrase: 123456 Verifying - Enter PEM pass phrase: 123456 ----- |
1
2
3
4
5
6
7
8
9
10
|
//确认密码输完回车后, 要求输入国家缩写, 只能2个字母 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) [AU]:CN |
1
2
3
|
//要求输入州名或省名 State or Province Name (full name) [Some-State]:Shanghai |
1
2
3
|
//要求输入城市名 Locality Name (eg, city) []:Shanghai |
1
2
3
|
//要求输入组织名或者公司名 Organization Name (eg, company) [Internet Widgits Pty Ltd]:yiban |
1
2
3
|
//要求输入部门名 Organizational Unit Name (eg, section) []:yiban |
1
2
3
|
//要求输入服务器域名或IP地址 Common Name (e.g. server FQDN or YOUR name) []:yiban |
1
2
3
|
//要求输入邮件地址 Email Address []:shawn0828@hotmail.com |
1
2
3
4
5
|
//要求输入密码 Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []:123456 |
1
2
3
|
//要求输入公司别名 An optional company name []:yiban |
1
2
3
|
//生成私钥,输入命令: D:\wamp\apache\bin>openssl rsa -in privkey.pem -out server.key |
1
2
3
4
|
//要求输入之前 privkey.pem 的密码 Enter pass phrase for privkey.pem: 123456 writing RSA key |
1
2
3
|
//创建证书,输入命令: D:\wamp\apache\bin>openssl x509 -in server.csr -out server.crt -req -signkey server.key -days 8000 |
1
2
3
4
5
6
7
|
//回车后, 显示创建成功, 有效期为 8000 天 Loading 'screen' into random state - done Signature ok subject=/C=CN/ST=Shanghai/L=Shanghai/O=yiban/OU=yiban/CN=yiban/emailAddress=shaw n0828@hotmail.com Getting Private key |
完成后, 将 \bin 下面的 server.csr、server.crt、server.key 拷贝到 [Apache安装目录]\conf\ssl 文件夹中, 没有则创建
再打开 [Apache安装目录]\conf\extra\httpd-ssl.conf 文件
替换 SSLCertificateFile 和 SSLCertificateKeyFile 语句对应的路径,例:
1
2
3
4
|
#SSLCertificateFile "D:/wamp/apache/conf/server.crt" //配置文件默认内容 //替换为 SSLCertificateFile "D:/wamp/apache/conf/ssl/server.crt" |
1
2
3
4
|
#SSLCertificateKeyFile "D:/wamp/apache/conf/server.key" //配置文件默认内容 //替换为 SSLCertificateKeyFile "D:/wamp/apache/conf/ssl/server.key" |
最后, 重启 Apache 服务器
在重启 Apache 时,若遇到 Apache 无法运行的情况
1
2
|
可以运行开始菜单中 Apache HTTP Server 2.2\Configure Apache Server\Test Configuration 来查找 httpd.conf 中的详细错误情况 |
1
|
或通过查看 Apache 安装目录下的 logs 文件夹内的 access.log 和 error.log 中的记录解决问题 |
如有更好的建议和代码片段,欢迎留言提出
最新文章
- CSS轮廓outline
- iOS 学习 - 10下载(2) NSURLSession 图片 篇
- nginx location在配置中的优先级
- IOS第18天(6,CAKeyframeAnimation关键帧动画)
- [简单]docx4j常用方法小结
- 269. Alien Dictionary
- JUnit使用参数测试和一组测试
- Entity Framework Core 命名约定
- Linaro系统获取root权限方法
- awk 里的substr()
- Android4.2.2源码目录结构分析
- 数据库MySQL——初识
- 好程序员分享Javascript设计模式
- 2018 Multi-University Training Contest 3 杭电多校第三场
- mysql系列九、mysql语句执行过程及运行原理(分组查询和关联查询原理)
- equals 与 == 的区别
- 转:sql语句优化
- JIRA 的字段配置
- 001.開始使用ASP.NET Web API 2(一)
- Uncaught SyntaxError: Invalid shorthand property initializer