CA数字证书服务
CA Certificate Authority 数字证书授权中心
被通信双方信任的,独立的第三方机构
负责证书颁发,验证,撤销等管理
PKI公钥基础设施
一套标准的密钥管理平台
通过公钥加密,数字证书技术确保信息安全
PKI体系的基础组成
权威认证机构(CA)
数字证书库,密钥备份及恢复系统
证书作废系统,应用接口
OpenSSL加密/解密工具
对称加密:
— enc 算法 -e -in 输入文件 -out 输出文件 #加密
— enc 算法 -d -in 输入文件 -out 输出文件 #解密
[[email protected] ~]# which openssl
/usr/bin/openssl
[[email protected] ~]# rpm -qf /usr/bin/openssl
openssl-1.0.1e-42.el7_1.9.x86_64
[[email protected] ~]# vim f1.txt
[[email protected] ~]# openssl enc -des3 -e -in f1.txt -out f1.txt.enc
enter des-ede3-cbc encryption password:
Verifying - enter des-ede3-cbc encryption password:
[[email protected] ~]# ls f1*
f1.txt f1.txt.enc
[[email protected] ~]# rm -rf f1.txt
[[email protected] ~]# openssl enc -des3 -d -in f1.txt.enc -out f1.txt
enter des-ede3-cbc decryption password:
[[email protected] ~]# ls f1*
f1.txt f1.txt.enc
部署CA服务器
第一步:配置CA签署环境
[[email protected] ~]# ls /etc/pki/CA/ #工作目录
certs crl newcerts private
[[email protected] ~]# ls /etc/pki/CA/certs/ #存储签发的数字证书
[[email protected] ~]# touch /etc/pki/CA/index.txt #存储发放出去的数字证书信息
[[email protected] ~]# chmod 600 /etc/pki/CA/index.txt
[[email protected] ~]# touch /etc/pki/CA/serial #证书编号文件
[[email protected] ~]# chmod 600 /etc/pki/CA/serial
[[email protected] CA]# echo 01 > serial
[[email protected] CA]# cat serial
01
[[email protected] ~]# vim /etc/pki/tls/openssl.cnf #调整配置
42 dir = /etc/pki/CA #CA签署工作目录
43 certs = $dir/certs #用户证书存放路径
44 crl_dir = $dir/crl
45 database = $dir/index.txt #存储发放出去的数字证书信息
50 certificate = $dir/my-ca.crt #CA根证书文件名
51 serial = $dir/serial #证书编号文件
55 private_key = $dir/private/my-ca.key #CA私钥文件名
130 countryName_default = CN
135 stateOrProvinceName_default = beijing
138 localityName_default = beijing
141 0.organizationName_default = Xuenqlve
148 organizationalUnitName_default = ope
84 [ policy_match ] #匹配策略
85 countryName = match
86 stateOrProvinceName = match
87 organizationName = match
88 organizationalUnitName = optional
89 commonName = supplied
90 emailAddress = optional
match 必须匹配
optional 可选
supplied 忽略
第二步:为CA生成私钥
[[email protected] ~]# cd /etc/pki/CA/private/
[[email protected] private]# openssl genrsa -des3 2048 > my-ca.key
Generating RSA private key, 2048 bit long modulus
.....................................................................+++
..+++
e is 65537 (0x10001)
Enter pass phrase: #设私钥口令
Verifying - Enter pass phrase: #重复私钥口令
[[email protected] private]# ls
my-ca.key
[[email protected] private]# chmod 600 my-ca.key
第三步:为CA服务器创建根证书
-new 新文件
-x509 证书的版式
./private/my-ca.key 私钥文件名
-day 365 有效日期
[[email protected] private]# cd ..
[[email protected] CA]# openssl req -new -x509 -key ./private/my-ca.key -days 365 > my-ca.crt
Enter pass phrase for ./private/my-ca.key:
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) [CN]:
State or Province Name (full name) [beijing]:
Locality Name (eg, city) [beijing]:
Organization Name (eg, company) [Xuenqlve]:
Organizational Unit Name (eg, section) [ope]:
Common Name (eg, your name or your server's hostname) []:Xuenqlve.ca.com
Email Address []:[email protected]
第四步:发布根证书
可以通过Web,FTP等方式进行发布
[[email protected] ~]# yum -y install httpd
[[email protected] ~]# systemctl stop firewalld
[[email protected] ~]# setenforce 0
[[email protected] ~]# systemctl restart httpd
[[email protected] ~]# systemctl enable httpd.service
[[email protected] ~]# mkdir /var/www/html/ca
[[email protected] ~]# cp /etc/pki/CA/my-ca.crt /var/www/html/ca/
客户端下载应用
[[email protected] ~]# wget http://192.168.4.2/ca/my-ca.crt
--2018-01-04 20:27:49-- http://192.168.4.2/ca/my-ca.crt
正在连接 192.168.4.2:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:1399 (1.4K)
正在保存至: “my-ca.crt”
100%[======================================>] 1,399 --.-K/s 用时 0s
2018-01-04 20:27:49 (141 MB/s) - 已保存 “my-ca.crt” [1399/1399])
[[email protected] ~]# firefox
进入火狐浏览器 点击浏览器右侧打开菜单--> 点击首选项
然后点击高级--->点击证书--->点击查看证书
点击证书机构--->点击导入
在计算机上找到刚刚下载的 my-ca.crt 证书 ---> 点击打开
勾选信任--->点击确定
然后就可以看见我们自己搭建的证书信息了
原文地址:http://blog.51cto.com/13558754/2057718