安装Apache
按照提示安装,比较简单,安装完毕以后,在浏览器中输入Apache的IP地址或者域名,如果能够出现“It works!”(这是Apache默认的一个网页\htdocs\Index.html),说明安装Apache已经成功,这时已经可以提供默认为80端口的http服务了;
生成CA证书和服务器证书
Ø 生成网站服务器公钥文件server.key :openssl genrsa-out server.key 1024
Ø 生成服务器证书请求文件server.csr:openssl req-new -out server.csr -key server.key -config ..\conf\openssl.cnf(Common Name为要申请域名证书的域名)
产生请求文件需要输入
期间有些需要输入的地方分别如下:
Enter PEM pass phrase: (输入密码)
Verifying – Enter PEM pass phrase: (再次输入密码)
Country Name (2 letter code) [AU]: (国家缩写)
State or Province Name (full name) [Some-State]: (省名)
Locality Name (eg, city) []: (城市名)
Organization Name (eg, company) [Internet Widgits Pty Ltd]: (组织名或者公司名)
Organizational Unit Name (eg, section) []: (部门名)
Common Name (eg, YOUR name) []: (服务器域名或IP地址)
Email Address []: (邮件地址)
Please enter the following ‘extra’ attributes
to be sent with your certificate request
A challenge password []: (密码)
An optional company name []: (公司别名)
输入密码
Ø 生成CA私钥文件ca.key :openssl genrsa -out ca.key 1024
Ø 生成CA证书:openssl req -new -x509 -days 365 -keyca.key -out ca.crt -config ..\conf\openssl.cnf
Ø 生成签名以后的服务器证书server.crt: openssl x509-req -in server.csr -out server.crt -CA ca.crt -CAkey ca.key -CAcreateserial
Ø 把server.crt,server.key,ca.crt文件复制到{Apache}/conf文件夹下面
Ø 把ca的证书(ca.crt)导入浏览器。
生成客户证书
若已有客户证书并已导入浏览器,可略过此步骤。
Ø 生成客户端证书 client.key
Ø 生成client.key :openssl genrsa-out client.key 1024
Ø 生成client.csr :openssl req-new -out client.csr -key client.key -config ..\conf\openssl.cnf
输入密码
Ø 生成客户证书 client.crt:
openssl x509 -req -days 365 -CA ca.crt -CAkeyca.key -CAcreateserial -in client.csr -out client.crt
Ø 将client.crt转换为 .pfx 格式的证书
openssl pkcs12 -export -clcerts -inclient.crt -inkey client.key -out client.p12
Ø 双击client.p12将其导入浏览器。
修改配置文件
打开httpd.conf进行下列操作:
1.1去掉下面语句的注释,即去掉前面的#
#LoadModule ssl_module modules/mod_ssl.so
1.2 去掉下面语句的注释,目的是使用Apache自带的ssl配置文件httpd-ssl.conf进行修改,减少我们的工作量。
#Include conf/extra/httpd-ssl.conf
打开apache/conf/extra/httpd-ssl.conf, 设置下列参数
SSLCertificateFile conf/server.crt(服务器证书路径)
SSLCertificateKeyFile conf/server.key (服务器私钥路径)
SSLCACertificateFile conf/ca.crt(CA证书路径)
SSLVerifyClient require
SSLVerifyDepth 1(此处根据ca证书证书级数配置,1为往上1级)