您的位置:首页 > 理论基础 > 计算机网络

建立基于https的web服务

2014-07-29 11:33 323 查看
先安装openssl
[root@CA ~]# yum install openssl


搭建私有CA服务器
修改openssl.cnf配置文件
[root@CA ~]# vim /etc/pki/tls/openssl.cnf
dir=/etc/pki/CA
创建相关的文件
[root@CA ~]# cd /etc/pki/CA
[root@CA ~]# makdir certs newcerts crl
[root@web ~]# touch index.txt
[root@web ~]# echo 01 > serial
生成一对密钥
[root@web ~]# (umask 077; openssl genrsa -out private/cakey.pem 2048)
生成自签证书
[root@web ~]# openssl req -x509 -new -key private/cakey.pem -out cacert.pem -days 3650
以上CA服务器搭建完成

Web服务器的https的搭建如下
例如为http服务生成密钥
[root@web ~]# (umask 077; openssl genrsa http.key 1024 )
生成证书颁发请求
[root@web ~]# openssl req -new -key http.key -out http.csr
将此请求文件(http.csr)传递给CA服务器
然后让CA服务器签署此证书
[root@CA ~]# openssl ca -in http.csr -out http.crt -days [number]
CA服务器再将签署好的证书发送给客户端

对apache做相关配置,开启SSL相关模块,启用SSL配置文件
[root@web apache~]# vim conf/httpd.conf
Include conf/extra/httpd-ssl.conf
修改httpd-ssl.conf文件,创建相关虚拟主机和开启SSL功能,指定SSLCertificateFile证书文件路径和SSLCertificatKeyFile密钥文件路径。重新启动http服务,查看是否监听443端口。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: