1. 把$apache-home\conf\目录下的openssl.cnf复制$apache-home\bin\目录
2. 创建一个根证书CA的一个RSA私用密钥
Ø Windows: openssl genrsa -out ca.key 1024
Ø Linux: openssl genrsa -des3 -out ca.key 1024
生成密钥ca.key
3. 利用CA的RSA密钥创建一个自签署的CA证书(X.509结构)
openssl req -new -x509 -days 3650 -key ca.key -out ca.crt
然后需要输入下列信息:
Country Name: cn 两个字母的国家代号
State or Province Name: An Hui 省份名称
Locality Name: Bengbu 城市名称
Organization Name: Family Network 公司名称
Organizational Unit Name: Home 部门名称
Common Name: 192.168.1.107 如果你的服务器有域名,添域名,如果没有添ip
Email Address:sunshine821126@gmail.com Email地址
生成ca.crt 文件
4. 为Apache创建一个RSA私用密钥
Ø Windows: openssl genrsa -out server.key 1024
Ø Linux: openssl genrsa -des3 -out server.key 1024
生成 server.key 文件
5. 用server.key生成服务器证书签署请求 CSR
openssl req–config openssl.cnf -new -key server.key -out server.csr
Common Name 这个属性请填写当前apache服务器的域名(如果不确定,请查看/conf/httpd.conf文件),如果填写不对,则apache不能正常启动 (域名如果查不到,可以写ip地址)
6. 生成服务器证书
1) 在当前目录下建立文件名为ca.config文件
文件内容如下ca.config:
################################################################
#cs.config example configuration file.
# This is mostly used for generation of certificate requests.
#################################################################
[ ca ]
default_ca= CA_own # The default ca section
#################################################################
[ CA_own ]
dir=. # Where everything is kept
certs=$dir # Where the issued certs are kept
crl_dir= $dir/crl # Where the issued crl are kept
database= $dir/ca.db.index # database index file
new_certs_dir= $dir/ca.db.certs # default place for new certs
certificate=$dir/ca.crt # The CA certificate
serial= $dir/ca.db.serial # The current serial number
#crl= $dir/crl.pem # The current CRL
private_key= $dir/ca.key # The private key
RANDFILE= $dir/ca.db.rand # private random number file
default_days= 365 # how long to certify for
default_crl_days= 30 # how long before next CRL
default_md= md5 # which message digest to use
preserve= no # keep passed DN ordering
# A few different ways of specifying how closely the request should
# conform to the details of the CA
policy= policy_anything
[ policy_anything ]
countryName = optional
stateOrProvinceName= optional
localityName= optional
organizationName = optional
organizationalUnitName = optional
commonName= supplied
emailAddress= optional
2) 在当前文件夹下面新建文件夹ca.db.certs
3) 在当前文件夹下面新建文件ca.db.index,内容为空
4) 在当前文件夹下面新建文件ca.db.serial,文件内容为
ca.db.serial:
01
(字符串01)
5) 输入命令: openssl ca –config ca.config –out server.crt –infiles server.csr
生成server.crt
7. 制作客户端证书(如同服务器)
1) 生成客户端密钥
openssl genrsa -out client.key 1024
生成client.key
2) 生成客户端证书签署请求 CSR
openssl req -new -key client.key -out client.csr
生成client.csr
3) 生成客户端证书
openssl ca –config ca.config –out client.crt –infiles client.csr
生成client.crt
4) 由于客户端证书不能直接使用,所以必须转化为其他格式
openssl pkcs12 -export -in client.crt -inkey client.key –out client.pfx
生成个人证书client.pfx
8. 导入证书server.crt和client.pfx
9. 将ca.crt和client.pfx,server.crt拷贝到window客户端并导入,导入是直接将ca.crt和client.pfx,server.crt文件依次安装证书:
在ie中的“工具”菜单的“Internet选项”进入选项卡:
导入的地址就是ca.crt和client.pfx,server.crt所在的路径
10. linux下将ca.crt, server.crt,server.key复制到conf/ssl目录下
11. 根据配置配置apache





