wamp3.0.6本地配置https

本博客主要参考 http://blog.csdn.net/sdq4700/article/details/36173665,在此基础上添加了本人在配置过程中所遇到的各种问题以及解决问题的办法。
环境:
wamp3.0.6+win10_64x
wamp目录:D:/wamp64
步骤:
1.利用cmd打开openssl.exe所在的目录,输入:
set OPENSSL_CONF=../conf/openssl.cnf  
ps:我最开始是使用的Xshell,发现了两个问题:
1.在执行后续命令的时候发现OPENSSL_CONF这个配置项没生效。
2.生成pfx文件的时候出现问题,没有提示,没有报错,就是一直卡着不动。
解决办法:使用cmd就可以了,至于为什么会这样,我也不知道。
2.生成需要的私钥
openssl genrsa > root.key   // 生成根密钥  
openssl genrsa > server.key  // 生成服务端密钥  
openssl genrsa > client.key  // 生成客户端密钥  
ps:可能会报错 “无法定位序数372”,这种情况是apache版本过高导致的,apache的bin目录里的libeay32.dll和ssleay32.dll文件都是快捷方式,且大小为0,我的解决办法是下载了一个wamp2.5,将里面的libeay32.dll,ssleay32.dll,openssl.cnf,openssl.exe文件复制过来。
3.生成自签名的根证书
openssl req -x509 -new -key root.key > root.crt
openssl req -new -key server.key -out server.csr
openssl req -new -key client.key -out client.csr
ps:每次输入命令成功后会要求输入一些信息,注意一致即可
wamp3.0.6本地配置https_第1张图片
4.在bin目录下面新建如下目录
md demoCA
md demoCA\newcerts
md demoCA\private
cd. > demoCA\index.txt
echo 01 > demoCA\serial
echo 01 > demoCA\crlnumber
5.生成pem文件
openssl genrsa -out demoCA/private/cakey.pem 2048  
openssl req -out demoCA/cacert.pem -x509 -new -key demoCA/private/cakey.pem 

6.使用根证书为服务端及客户端签名
openssl ca -in server.csr -cert root.crt -keyfile root.key -out server.crt  
openssl ca -in client.csr -cert root.crt -keyfile root.key -out client.crt  
ps:在生成签名的时候可能会报错:failed to upadate database TXT_DB error number 2,在demoCA文件夹下打开index.txt.attr文件,将yes改为no即可

7.将客户端证书转成pfx格式,并在浏览器上导入该证书
openssl pkcs12 -export -clcerts -in client.crt -inkey client.key out client.pfx  
8.配置http.conf,所在位置E:\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  

9.配置http-ssl.conf,所在位置E:\wamp\bin\apache\apache2.4.9\conf\extra\http-ssl.conf(只列出修改部分)
SSLSessionCache "shmcb:E:/wamp/logs/ssl_scache"  
Mutex default  
  
DocumentRoot "E:/wamp/www"  
ServerName localhost:443  
ServerAdmin [email protected]  
ErrorLog "E:/wamp/logs/apache_error.log"  
TransferLog "E:/wamp/logs/access.log"   
SSLEngine on  
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL  
SSLCertificateFile "E:/wamp/bin/apache/apache2.4.9/bin/server.crt"  
SSLCertificateKeyFile "E:/wamp/bin/apache/apache2.4.9/bin/server.key"  
SSLCACertificateFile "E:/wamp/bin/apache/apache2.4.9/bin/root.crt"  
SSLVerifyClient require  
SSLVerifyDepth  10  
  
     SSLOptions +StdEnvVars +ExportCertData  
  
CustomLog "E:/wamp/logs/ssl_request.log" \  
          "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
  
ps.配置完成,重启wamp时可能会出现apache无法启动的情况,而且日志文件里也没有报错,在系统的事件查看器里倒是有相关信息,但全是16进制的,也看不出来原因。多方查找,发现还是版本的问题,真是日了哈士奇了。高版本的wamp里缺少了libssl32.dll文件,下了一个openssl1.0.2k_64x,为了防止版本再次不匹配,将里面的libeay32.dll,ssleay32.dll,libssl32.dll全部拷了过来。重启apache成功。

你可能感兴趣的:(环境搭建,协议相关)