SSL证书是数字证书的一种,类似于驾驶证、护照和营业执照的电子副本。因为配置在服务器上,也称为SSL服务器证书。
SSL证书就是遵守 SSL协议,由受信任的数字证书颁发机构CA,在验证服务器身份后颁发,具有服务器身份验证和数据传输加密功能。
HTTPS和HTTP的区别主要为以下四点:
一、https协议需要到ca (Certificate Authority)申请证书,一般免费证书很少,需要交费。
二、http是超文本传输协议,信息是明文传输,https 则是具有安全性的ssl加密传输协议。
三、http和https使用的是完全不同的连接方式,用的端口也不一样,前者是80,后者是443。
四、http的连接很简单,是无状态的;HTTPS协议是由SSL+HTTP协议构建的可进行加密传输、身份认证的网络协议,比http协议安全。
SSL建立过程
三次握手
协商算法
服务器发送证书给客户端
客户端生成对称密钥
客户端发送http请求
服务器通过对称密钥加密后把网页送到客户端
安装
[root@localhost ~]# yum install mod_ssl -y
创建证书
[root@localhost ~]# cd /etc/pki/tls/certs/
[root@localhost certs]# make xixi.crt
Enter pass phrase: 证书密码
Verifying - Enter pass phrase: 确认密码
Enter pass phrase for xixi.key: 再次输入密码
Country Name (2 letter code) [XX]:CN 国家代码
State or Province Name (full name) []:shaanxi 省份
Locality Name (eg, city) [Default City]:xian 城市
Organization Name (eg, company) [Default Company Ltd]:gongcheng.cn 公司名称
Organizational Unit Name (eg, section) []:tech 部门
Common Name (eg, your name or your server's hostname) []:www.xian.com 真实域名
Email Address []:xian@gongcheng.cn E-mail地址
HTTP网站配置
[root@localhost certs]# vim /etc/httpd/conf.d/vhost.conf
<Directory /www>
AllowOverride none 允许覆盖
Require all granted 设置访问目录权限
</Directory>
<VirtualHost 192.168.121.131:443>
ServerName 192.168.121.131 服务名
DocumentRoot /www 根目录
SSLEngine on 引擎打开
SSLProtocol all -SSLv2 所支持的协议,除SSLv2
SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5 密码套件客户端和服务端
SSLCertificateFile /etc/pki/tls/certs/xixi.crt 证书路径
SSLCertificateKeyFile /etc/pki/tls/certs/xixi.key 密钥路径
</VirtualHost>
[root@localhost certs]# mkdir /www 创建目录
[root@localhost certs]# echo https > /www/index.html 网页追加
[root@localhost certs]# systemctl restart httpd 开启服务
Enter SSL pass phrase for 192.168.121.131:443 (RSA) : ****** 输入证书密码
检验: