锐盾KVM400客服电话
KVM切换器

Windows如何搭建SSL安全访问服务器

发布时间:1506327769 作者:Reton技术部

因为看到网上的各种教程不全还有很多错误,自己绕了好多弯最后参考了官方文档,才最终解决,所以这里综合各方大神所写的文章,改正和完善细节后再发一次。这里不得不说一下,官方文档虽然是英文的平时还特别低调,显得相当高冷,可是它却是我们最靠谱,最坚强的后盾。

1.修改两个配置文件,一个为conf/httpd.conf,另一个为conf/extra/httpd-ssl.conf

在httpd.conf中
a. 删掉以下语句前的’#’

b. httpd-ssl.conf中把相应选项改成如下,有’#’的删掉

2.生成各种证书
进入Apache24\bin目录,在对应文件夹下打开cmd
这里需要一个openssl的配置文件openssl.cnf,如果他不在 conf文件夹下,可以去网上下一个,建议把它放到bin目录下,这样子敲命令比较方便

a. 首先要生成服务器端的私钥(key文件):

  set OPENSSL_CONF=openssl.cnf
  openssl genrsa -des3 -out server.key 1024

b. 生成server.csr ,Certificate Signing Request(CSR),生成的csr文件交给CA签名后形成服务端自己的证书.屏幕上将有提示,依照其指示一步一步输入要求的个人信息即可.

openssl req -new -key server.key -out server.csr -config openssl.cnf

c. 对客户端也作同样的命令生成key及csr文件

openssl genrsa -des3 -out client.key 1024
openssl req -new -key client.key -out client.csr -config openssl.cnf

d. CSR文件必须有CA的签名才可形成证书.可将此文件发送到verisign等地方由它验证,要交一大笔钱,何不自己做CA呢.

openssl req ca.key -out ca.crt -config openssl.cnf

e. 在bin目录下新建一个demoCA文件夹,进入它
新建newcerts文件夹,不需要进入
新建index.txt
新建serial,打开后输入01保存即可

f. 用生成的CA的证书为刚才生成的server.csr,client.csr文件签名:

openssl ca -in server.csr -out server.crt -cert ca.crt -keyfile ca.key -config openssl.cnf

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

这里如果第二条指令出现下面这样的错误,进入demoCA,然后打开index.txt.attr,把它修改成unique_subject = no就可以了

出错信息

 

g. 生成一个ca.pfx,打开IE浏览器-》工具-》Internet选项-》内容-》证书,按照提示导入,这里要输入刚才生成 .pfx 过程中输入的密码
openssl pkcs12 -export -in ca.crt -inkey ca.key -out ca.pfx.

以上操作生成了
client使用的文件有:ca.crt,client.crt,client.key
server使用的文件有:ca.crt,server.crt,server.key

把 ca.crt,server.crt,server.key复制到conf根目录下去

打开Apache Service Monitor ,点击重启或者启动,走你…..
然而并没什么卵用,apache爆炸了,可是我们并不需要报警,接下来我们将一步步解决这些错误,本人行走江湖多年,能力不高,所以错误百出,别的没能耐,但是对于找错误,还是相当有一手的(此处捂着嘴笑),下面贴出logs/error.log的错误信息

] [] is not configured [hint: SSLSessionCache]

[] [] worker threads.

[] [] restart signal -- Restarting the server.

error on line session cache not supported (known names: ). Maybe you need to load the appropriate socache module (mod_socache_shmcb?).

[] [] worker threads have exited.

各种百度以后得到解决方案

session cache not supported (known names: ). Maybe you need to load the appropriate socache module (mod_socache_shmcb?).

在httpd.conf中找到下面这句话
#LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
取消注释(删掉前面的"#"2.SSLPassPhraseDialog builtin is not supported on Win32(key file C:/Apache24/conf/server.key)

   这个是说Windows不支持加密密钥,还记得生成server.key输入的密码吗?没错就是它的锅,我们现在取消掉它,cmd输入

openssl rsa -in server.key -out server.key

把生成的server.key复制到conf目录下覆盖
然后打开httpd-ssl.conf 找到SSLPassPhraseDialog  builtin 在前面加上#

然后再次点击apache上的启动试试,然后就SSL走起了。
浏览器输入https://127.0.0.1/index.php就可以观望到自己的https站点了。

(责任编辑:Reton技术部)
在百度搜索更多 Windows如何搭建SSL安全访问服务器

上一篇: 苹果闷声发大财东芝芯片买主终于敲定        KVM切换器
KVM切换器
<