SSL
SSL(Secure Sockets Layer 安全套接层),及其继任者传输层安全(Transport Layer Security,TLS)是为网络通信提供安全及数据完整性的一种安全协议。TLS与SSL在传输层对网络连接进行加密。
Secure Socket Layer,为Netscape所研发,用以保障在Internet上数据传输之安全,利用数据加密(Encryption)技术,可确保数据在网络上之传输过程中不会被截取及窃听。一般通用之规格为40 bit之安全标准,美国则已推出128 bit之更高安全标准,但限制出境。只要3.0版本以上之I.E.或Netscape浏览器即可支持SSL。
当前版本为3.0。它已被广泛地用于Web浏览器与服务器之间的身份认证和加密数据传输。
SSL协议位于TCP/IP协议与各种应用层协议之间,为数据通讯提供安全支持。SSL协议可分为两层: SSL记录协议(SSL Record Protocol):它建立在可靠的传输协议(如TCP)之上,为高层协议提供数据封装、压缩、加密等基本功能的支持。 SSL握手协议(SSL Handshake Protocol):它建立在SSL记录协议之上,用于在实际的数据传输开始前,通讯双方进行身份认证、协商加密算法、交换加密密钥等。
一.配置ssl安全协议
[root@apache-server html]# yum install mod_ssl -y
[root@apache-server html]# yum install crypto-utils.x86_64 -y
[root@apache-server html]# genkey www.westos.com
[root@apache-server html]# vim /etc/httpd/conf.d/ssl.conf
100 #SSLCertificateFile /etc/pki/tls/certs/localhost.crt
101 SSLCertificateFile /etc/pki/tls/certs/www.westos.com.crt
108 #SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
109 SSLCertificateKeyFile /etc/pki/tls/private/www.westos.com.key
[root@apache-server html]# systemctl restart httpd.service
在网页https://172.25.254.249
1.在服务端下载mod_ssl crypto-utils两个软件
crypto-utils 加密工具
mod_ssl ssl加密协议创建工具
2.加密www.westos.com
3.加密完成后,会生成两个关于加密信息的文件,将这两个文件添加到ssl服务的配置文件里面
4.在火墙服务里面添加https,HTTPS的默认端口为443,并重新启服务动
5.在网页上https://ip
6.获取加密,加密协议生效
二.设定虚拟主机网页重写
mkdir /var/www/westos.com/login/html
vim /var/www/westos.com/login/html/index.html
<h1>login's page</h1>
[root@apache-server html]# vim /etc/httpd/conf.d/login.conf
<VirtualHost *:443>
ServerName login.westos.com
DocumentRoot /var/www/westos.com/login/html
Customlog logs/login.log combined
SSLEngine on
SSLCertificateFile /etc/pki/tls/certs/www.westos.com.crt
SSLCertificateKeyFile /etc/pki/tls/private/www.westos.com.key
</VirtualHost>
<Directory "/var/www/westos.com/login/html">
Require all granted
</Directory>
<VirtualHOST *:80>
serverName login.westos.com
RewriteEngine On
RewriteRule ^(/.*)$ https://%{HTTP_HOST}$1 [redirect=301]
</VirtualHost>
[root@apache-server html]# systemctl restart httpd.service
1.创建一个login.westos.com的虚拟主机,发布目录在/var/www/westos.com/login/html/index.html
2.编辑虚拟主机发布目录的配置文件
^(/.*)$ ##客户在浏览器地址栏中输入所有字符
https:// ##强制客户加密访问
%{HTTP_HOST} ##客户请求主机
$1 ##“
1
”
表
示
(
/
.
∗
)
1”表示 ^(/.*)
1”表示(/.∗)的值
[redirect=301] @@永久重写 302临时
3.重新启动服务,并在真机上添加本地解析login.westos.com,再在网页上访问,会发现自动跳转ssl加密协议
获取ssl加密协议