以apache为例,演示申请CA证书过程
1、查看http的钥匙和证书存放位置
[root@redhat7 ~]# vim /etc/httpd/conf.d/ssl.conf
2、生成钥匙和证书
[root@redhat7 ~]# openssl genrsa 1024 > /etc/pki/tls/private/localhost.key
[root@redhat7 ~]# openssl req -new -key /etc/pki/tls/private/localhost.key -out redhat7.csr
3、将证书传给CA机构
CA机构制作方法参考《制作CA机构》文档。
[root@redhat7 ~]# scp redhat7.csr centos7:/tmp/
4、CA机构颁发证书
会报错:说index.txt文件没有读取到,这一步会产生一些报错,会报一些文件或者文件夹没有,新建就行,缺什么建什么。
[root@centos7 tmp]# touch /etc/pki/CA/index.txt
[root@centos7 tmp]# touch /etc/pki/CA/serial
[root@centos7 tmp]# echo 01 > /etc/pki/CA/serial
5、CA机构将文件传给客户端(apache服务器)。
[root@centos7 tmp]# scp redhat7.crt redhat7:/tmp/
6、客户端(apache服务器)将证书放到指定目录
[root@redhat7 ~]# vim /etc/httpd/conf.d/ssl.conf
[root@redhat7 ~]# cp /tmp/redhat7.crt /etc/pki/tls/certs/localhost.crt
7、将CA机构的证书传输给客户端(apache服务器)
PS:CA机构证书是公开的,任何一个浏览器都可以拿到
[root@centos7 tmp]# scp /etc/pki/CA/cacert.pem redhat7:/tmp/
8、客户端(apache服务器)将CA证书放到指定目录
[root@redhat7 ~]# cp /tmp/cacert.pem /etc/pki/tls/certs/ca-bundle.crt
在/etc/httpd/conf.d/ssl.conf文件里面将CA机构证书存放位置打开。
9、启动apache
[root@redhat7 ~]# systemctl restart httpd
10、访问apache
[root@redhat7 ~]# echo Cool > /var/www/html/index.html
还是不可信的连接,查看证书信息
11、将CA证书导入浏览器
再次打开,现在为可信的连接。