(2)证书安全性
一、利用windows2008做ca
此时CA服务器器已经做好
CA客户端得像CA服务器做一个请求,使用一个工具openssl,用这个工具产生一个请求文件
[root@workstation253 ~]# cd /etc/httpd/
[root@workstation253 httpd]# mkdir certs (创建一个目录,存放所有请求文件,钥匙等)
[root@workstation253 httpd]# cd certs/
先做钥匙,在根据钥匙产生请求文件
[root@workstation253 certs]# openssl genrsa 1024 (产生非对称加密算法,1024位长度)
Generating RSA private key, 1024 bit long modulus
..............................................++++++
..++++++
e is 65537 (0x10001)
-----BEGIN RSA PRIVATE KEY-----
MIICXQIBAAKBgQDImDeuIH3QvvlQJOFHomeSEosRNb6+WbKmkNzkwC9dDr6h2YOp
K9JBM/d+ajQbJy0h94qaRqx6GurJCBCTCwuABEqZAzAUL4N/SmMbNnNGI7kV51C0
2GAIeBIOVMaCE7FUvlIpnGt7kA6hEWXtRPA1pT3NHQMC1Hy6qqDh2P1gjQIDAQAB
AoGAQwJ+jz+xZ/t0A67eRvTcznI9XLlsh+AlCvmXoR8Gc3rKefzUu7201i1K/0Lx
NyTmMdOkzJbRZVT6m7+C8ewdocWrkvlsZpq+eZWqCLFghDBTbSObLBFpD45L/bvb
j8D94ICWZWzU2QLNHEcQ3CzCP2HWnPrZrXFtDgBv5QiyiGECQQDvZqjtluWlG+m6
Aq1/gLczkEx9bSikoBLgva56MhzxB9julQlyUnuto7nFJ8Rhr1+RlC5NofdH6Y8d
mkxR/JBZAkEA1oC/jrZnIlt3WNaYor04CSz3rvIKFa9d9fTgG2ROKdWVseMa6VlZ
aXYazfFMGboj5O+8MJPHVF8SXp3RoqarVQJBALWax9zr0isM4KGldF27k73+4bdn
/iPb9lYcLeYua7wAOvTJhBAAOCgBgmPoBdYghjvWD8X+bqpTp6hKK0kqcYkCQCUq
O4Zjji0CwgPvcpTHyhy04Nk78IlfUB1cZzP3xh8zdXNT0QbbR0Whg/VouHHAsZVq
ACY+hIvWyR0BpR/UVt0CQQCmPbK1k9pom9PaFK9iBdM9WiOq56GjFnMIU9T+j+9z
oc+MO+YEh2lFZxriy3IE2bcAeKayESTfHbDlHfFIGMu0
-----END RSA PRIVATE KEY----- (产生了私钥,但是里面包含公钥)
[root@workstation253 certs]# openssl genrsa 1024 >httpd.key (产生钥匙文件)
Generating RSA private key, 1024 bit long modulus
........++++++
.............................++++++
e is 65537 (0x10001)
[root@workstation253 certs]# chmod 600 httpd.key (为了安全起见更改钥匙文件的权限)
根据钥匙文件产生一个证书的请求
[root@workstation253 certs]# openssl req -new -key httpd.key -out httpd.csr 输出请求文件
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [GB]:CN 国家
State or Province Name (full name) [Berkshire]:HENAN 省份
Locality Name (eg, city) [Newbury]:ZHENGZHOU 城市
Organization Name (eg, company) [My Company Ltd]:ll 单位名
Organizational Unit Name (eg, section) []:tec 部门名
Common Name (eg, your name or your server's hostname) []:www.ll.com 为哪个服务器申请
Email Address []:
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
[root@workstation253 certs]# ll
total 8
-rw-r--r-- 1 root root 643 Sep 8 00:55 httpd.csr 产生了这个请求文件
-rw------- 1 root root 887 Sep 8 00:47 httpd.key
CA客户端把请求文件发给CA
CA客户端证书的下载:
将证书转移:
root@ttttttttt Server]# cd /etc/httpd/certs/
[root@ttttttttt certs]# ll
-rw-r--r-- 1 root root 1016 09-04 11:38 certnew.cer
-rw-r--r-- 1 root root 643 09-04 11:01 httpd.csr
-rw------- 1 root root 891 09-04 11:00 httpd.key
CA客户端证书的安装:
[root@ttttttttt Server]# yum -y install mod_ssl 安装mod_ss包
[root@ttttttttt certs]# vim /etc/httpd/conf.d/ssl.conf 编译mod_ss的配置文件
LoadModule ssl_module modules/mod_ssl.so ssl动态模块
Listen 443 监听端口为443
SSLCertificateFile /etc/httpd/certs/certnew.cer 指明证书文件
SSLCertificateKeyFile /etc/httpd/certs/httpd.key 指明证书对应密钥文件
然后重启http服务
在www服务器客户端访问这个接受过证书的CA证书的www服务器时,将服务器的证书设置为受信任:
使用linux做CA
自己做自签发的证书:
(1)产生自己的私钥并指明CA的目录
[root@ttttttttt ~]# cd /etc/pki/CA/ 切换待CA目录下
[root@ttttttttt CA]# ll
drwx------ 2 root root 4096 2010-03-12 private
[root@ttttttttt CA]# openssl genrsa 1024 >private/cakey.pem
Generating RSA private key, 1024 bit long modulus
....................................................................................++++++
..................++++++
e is 65537 (0x10001)
[root@ttttttttt CA]# chmod 600 private/* 更改私钥文件的权限
编译[root@ttttttttt ~]# vim /etc/pki/tls/openssl.cnf
45 dir = /etc/pki/CA 指明CA的目录
(2)产生一个自签发的证书(不需要请求文件)
[root@ttttttttt CA]# openssl req -x509 -new -key private/cakey.pem -out cacert.pem -days 3655
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
Country Name (2 letter code) [GB]:CN
State or Province Name (full name) [Berkshire]:HENAN
Locality Name (eg, city) [Newbury]:ZHENGZHOU
Organization Name (eg, company) [My Company Ltd]:TT
Organizational Unit Name (eg, section) []:TEC
Common Name (eg, your name or your server's hostname) []:rootca.tt.com
Email Address []:
[root@ttttttttt CA]# ll
-rw-r--r-- 1 root root 1123 09-05 03:09 cacert.pem 产生的证书文件
drwx------ 2 root root 4096 09-05 03:03 private
(3)让CA给服务器颁发证
[root@ttttttttt CA]# cd /etc/httpd/certs/
[root@ttttttttt certs]# opensslgenrsa 1024 >httpd.key
-bash: opensslgenrsa: command not found
You have new mail in /var/spool/mail/root
[root@ttttttttt certs]# openssl genrsa 1024 >httpd.key
Generating RSA private key, 1024 bit long modulus
...++++++
......................................++++++
e is 65537 (0x10001) 产生一个钥匙文件
[root@ttttttttt certs]# openssl req -new -key httpd.key -out httpd.csr
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
Country Name (2 letter code) [GB]:CN
State or Province Name (full name) [Berkshire]:HENAN
Locality Name (eg, city) [Newbury]:ZHENGZHOU
Organization Name (eg, company) [My Company Ltd]:LL
[root@ttttttttt certs]# openssl req -new -key httpd.key -out httpd.csr
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
Country Name (2 letter code) [GB]:CN
State or Province Name (full name) [Berkshire]:HENAN
Locality Name (eg, city) [Newbury]:ZHENGZHOU
Organization Name (eg, company) [My Company Ltd]:TT
Organizational Unit Name (eg, section) []:TEC
Common Name (eg, your name or your server's hostname) []:www.ll.com
Email Address []:
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
产生一个请求
[root@ttttttttt certs]# ll
-rw-r--r-- 1 root root 643 09-05 03:23 httpd.csr 产生的请求文件
-rw-r--r-- 1 root root 887 09-05 03:20 httpd.key 产生的密钥文件
(4)为客户端签发证书
[root@ttttttttt etc]# cd /etc/httpd/certs/
[root@ttttttttt certs]# openssl ca -in httpd.csr -out httpd.crt
Using configuration from /etc/pki/tls/openssl.cnf
Check that the request matches the signature
Signature ok
Certificate Details:
Serial Number: 1 (0x1)
Validity
Not Before: Sep 4 19:50:10 2011 GMT
Not After : Sep 3 19:50:10 2012 GMT var cpro_id = "u6885494";