在网站建设中的apache安全设置ssl连接:
1、支持SSL通信,配置SSL证书。
在Apache的conf\extra目录中用文本编辑器打开httpd-ssl.conf
1.1修改
SSLMutex file:logs/ssl_mutex
为SSLMutex default
(注:Apache2.2中,直接就是SSLMutex default)
1.2删除以下两行(如果有):
<IfDefine SSL>
</IfDefine>
1.3目录访问权限
<Directory"D:/web/www/thinkphp/MyTp">
Options -Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
1.4打开Apache配置文件(httpd.conf),去掉这行的注释
#LoadModule ssl_module modules/mod_ssl.so
打开该模块,否则BrowserMatch这里会报错
#LoadModule setenvif_module modules/mod_setenvif.so
(Apache中#表示注释,去掉#即可)
1.5在httd.conf中找到
# Secure (SSL/TLS) connections
#Include conf/extra/httpd-ssl.conf
在其下方添加
Include conf/httpd-ssl.conf
这样就可以把ssl.conf包含在内(也可以是httpd-ssl.conf, 视步骤1而定)
2,如果安装带ssl的apache的话,apache目录下就有该文件openssl.cnf,注意一定放到%apache%\bin\下,
3,创建一个SSL证书。你可以打开一个命令行窗口,然后cd到%apache%\bin\
3.1 敲入命令openssl genrsa -outserver.key 1024,生成一个server.key
3.2 生成签署申请
敲入命令openssl req -new-out server.csr -key server.key -config ..\conf\openssl.cnf,生成一个签署文件server.csr
4,在自己的机器上搭建一个企业内部CA
4.1 敲入命令openssl genrsa -out ca.key1024生成企业内部私钥ca.key
4.2 敲入命令openssl req -new-x509 -days 365 -key ca.key -out ca.crt -config ..\conf\openssl.cnf 利用CA私钥生成CA自签署证书,此时生成一个CA证书ca.crt
5 为网站服务器签署证书
5.1 创建目录文件结构存放相应文件(在bin文件夹下新建目录demoCA, 建立newcerts, index.txt, serial无扩展名文件,内容01)
5.2敲入命令
openssl ca -in server.csr -out server.crt -cert ca.crt -keyfile ca.key -config..\conf\openssl.cnf生成证书server.crt。
5.3最后一步,把server.crt和server.key拷贝到目录conf下
5.4,生成客户端证书和ca证书
openssl pkcs12 -export -inserver.crt -inkey server.key -out server.pfx
openssl pkcs12 -export -inca.crt -inkey ca.key -out ca.pfx
5.5,重新启动Apache即可.
6,导入证书,验证,
6.1,IE--> 工具-->internet选项-->内容-->证书-->导入-->下一步-->浏览-->导入生成的证书。
6.2打开IE根目录验证,配置成功之后,成功访问Apache服务器htdocs目录下网页