设置apache https服务

  • 配置http.conf,所在位置d:\wamp\bin\apache\apache2.4.9\conf\http.conf
 
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
LoadModule sslmodule modules/modssl.so
Include conf/extra/httpd-ssl.conf
 
  • 配置http-ssl.conf,所在位置d:\wamp\bin\apache\apache2.4.9\conf\extra\http-ssl.conf
 
# 注意路径都改到wamp的目录下
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
SSLSessionCache "shmcb:E:/wamp/logs/ssl_scache"
DocumentRoot "d:/wamp/www"
ServerName localhost:443
ErrorLog "d:/wamp/logs/apache_error.log"
TransferLog "d:/wamp/logs/access.log"
 
SSLCertificateFile "d:/wamp/bin/apache/apache2.4.9/bin/server.crt"
SSLCertificateKeyFile "d:/wamp/bin/apache/apache2.4.9/bin/server.key"
SSLCACertificateFile "d:/wamp/bin/apache/apache2.4.9/bin/ca.crt"
 
# 要求进行客户端认证,如果是双向认证,需要打开
SSLVerifyClient require        
SSLVerifyDepth  1
 
CustomLog "d:/wamp/logs/ssl_request.log"
 
  • 生成证书
# openssl程序,在wamp\bin\apache\apache2.4.9\bin目录下
 
生成私钥
openssl> genrsa -out ca.key 2048
openssl> genrsa -out server.key 2048
openssl> genrsa -out client.key 2048
 

自签署ca证书

openssl> req -x509 -new -key ca.key -out ca.crt -config ../conf/openssl.cnf -days 365
 
# 因为是根证书,这里的Common Name只填显示名称即可
 
说明:
Country Name 国家代码(只支持两位字符)
Province Name 省份
Locality Name 城市
Organization Name 公司名称
Organizational Unit Name 组织名称
Common Name (申请证书的域名或IP地址)  
Email Address 管理员邮箱  
 

服务端申请签署资料生成

 
req -new -key server.key -out server.csr -config ../conf/openssl.cnf -days 365
 
# 需注意国家、省、市这些资料,必需和根证书CA一样,不然没法用CA签证
# Common Name为当前服务器IP或域名
 
客户端申请签署资料生成
req -new -key client.key -out client.csr -config ../conf/openssl.cnf -days 365
 
建立CA自签目录
wamp\bin\apache\apache2.4.9\bin目录下
 
mkdir -p ./demoCA/newcerts
touch ./demoCA/index.txt
echo 01 > ./demoCA/serial
echo 01 > ./demoCA/crlnumber
 
 

用ca证书给服务端签名

 
ca -in server.csr -cert ca.crt -keyfile ca.key -out server.crt  -config ../conf/openssl.cnf
 
# 注意生成之后,需要清空demoCA/index.txt里面的内容,不然给下一个签证时会报错
 
 

用ca证书给客户端签名

 
ca -in client.csr -cert ca.crt -keyfile ca.key -out client.crt  -config ../conf/openssl.cnf
 
 

生成客户端使用证书

 
pkcs12 -export -clcerts -in client.crt -inkey client.key -out client.pfx
 
--------------------------------------
  • 测试使用
 
 
因为证书不是机构所发,所以会提示这个
 
  • 导入CA根证书
此时访问就ok了
posted @   Athrun  阅读(437)  评论(0编辑  收藏  举报
编辑推荐:
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
阅读排行:
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 字符编码:从基础到乱码解决
历史上的今天:
2015-01-06 [转]用chrome模拟微信浏览器访问需要OAuth2.0网页授权的页面
2009-01-06 ASP中利用OWC控件实现图表功能详解
点击右上角即可分享
微信分享提示