http协议都是明文的,所以在基于Authtype控制访问页面的时候,利用抓包工具我们可以看到用户的账户和密码。https就是加密传输。对传输的数据进行加密
ssl会话过程
-
1、客户端发送可供选择的加密方式,并向服务器请求整数
-
2、服务器端发送证书以及选定的加密方式给客户端
-
3、客户端取得证书并进行证书验证,证书有以下几点注意
- 如果信任其给的证书
- a、验证证书的来源合法性;用CA的公钥解密证书上数字签名
- b、验证证书的内容的合法性,完整性验证
- c、检查证书的有效期限
- d、检查证书是否被吊销
- e、证书中拥有者的名字,与访问的目标主机要一致
- 4、客户端生成临时会话密钥(对称密钥),并使用服务器端的公钥加密比数据发送服务器,完成密钥交换
- 5、服务器用此密钥加密用户请求的资源,响应给客户端
ssl是基于ip地址实现,单ip地址的主机仅可以使用一个https虚拟机
- 如果信任其给的证书
https实现
首先创建私有ca自签证书
1)在CA主机上生成密钥
[root@CA CA]# (umask 066;openssl genrsa -out private/cakey.pem 2048)
Generating RSA private key, 2048 bit long modulus
...........................+++
......................+++
e is 65537 (0x10001)
2)在CA主机上生成自签证书
[root@CA CA]# openssl req -new -key private/cakey.pem -x509 -out cacert.pem -days 3650
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) [XX]:CN
State or Province Name (full name) []:beijing
Locality Name (eg, city) [Default City]:beijing
Organization Name