1.概述
为了加强网站安全访问策略,在现有 xxx网站 Apahce Server加入SSL功能,当访问特定目录时,需要提供SSL证书要求,以保证合法用户才能访问.
2.软件要求
JDK:1.5
Apache:2.2.9+ssl
Tomcat:5.0(Apache与tomcat组合)
3.操作步骤
3.1设置配置文件环境
CMD 启动命令行窗口 切换到Apache Bin目录
set OPENSSL_CONF=openssl.cnf(命令行下openssl.cnf相对路径)
3.2创建Server SSL证书
1.openssl req -new -out my-server.csr
2.openssl rsa -in privkey.pem -out my-server.key
3.openssl x509 -in my-server.csr -out my-server.cert -req -signkey my-server.key -days 4000(有效期-天)
4.openssl x509 -in my-server.cert -out my-server.der.crt -outform DER
3.3设置Server ssl 目录
在conf 新建目录ssl 将bin 目录下产生的六个文件拷贝到该目录下. .cnt, privkey.pem, my-server.der.crt, my-server.scr, my-server.key, my-server.cert
3.4设置配置文件(httpd.conf)
去掉下面 设置行前面的#
LoadModule ssl_module modules/mod_ssl.so
Include conf/extra/httpd-ssl.conf
3.5设置配置文件(httpd-ssl.conf conf/extra目录中)
1.SSLMutex default
2.SSLCertificateFile "[Apache安装目录]/conf/ssl/my-server.der.crt"
3.SSLCertificateKeyFile "[Apache安装目录]/conf/ssl/my-server.key"
4.SSLVerifyClient require(必须) optional(可选) none(不要求)
5.SSLVerifyDepth 10
6.SSLOptions +StdEnvVars +ExportCertData(导出证书信息)
7
- .<FilesMatch "/.(jsp|cgi|shtml|phtml|php)$">
- SSLOptions +StdEnvVars +ExportCertData
- </FilesMatch>
.<FilesMatch "/.(jsp|cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars +ExportCertData
</FilesMatch>
8
- .<Directory "E:/apache-tomcat-5.5.17/webapps/ROOT/ssl(指定https目录)">
- SSLOptions +StdEnvVars +ExportCertData
- Options FollowSymLinks
- AllowOverride FileInfo
- </Directory>
.<Directory "E:/apache-tomcat-5.5.17/webapps/ROOT/ssl(指定https目录)">
SSLOptions +StdEnvVars +ExportCertData
Options FollowSymLinks
AllowOverride FileInfo
</Directory>
9.DocumentRoot "E:/apache-tomcat-5.5.17/webapps/ROOT/ssl"(指定https目录)
10. <VirtualHost _default_:443>目录下加入相关处理
JkMount /servlet/* myloadbalancer
JkMount /*.jsp myloadbalancer
JkMount /*.do myloadbalancer
JkMount /* myloadbalancer
3.6客户证书(KEY)生成
- 1.openssl genrsa -des3 -out client.key 1024
- 2.openssl req -new -x509 -days 3650 -key client.key -out client.crt
1.openssl genrsa -des3 -out client.key 1024
2.openssl req -new -x509 -days 3650 -key client.key -out client.crt
(输入颁发者信息)
3.在conf目录下新建sslc目录
4.将client.crt拷贝到新建的sslc目录,修改httpd-ssl.conf 文件中SSLCACertificateFile 文件路径为client.crt文件路径
3.7客户浏览器证书生成
- 1.openssl req -new -out pony.csr(输入客户信息)
- 2.openssl x509 -req -in pony.csr -out pony.crt -signkey client.key -CA client.crt -CAkey client.key -CAcreateserial -days 3650(有效期-天)
- 3. openssl pkcs12 -export -in pony.crt -inkey client.key -out pony.pfx