https:http over ssl

1.SSL会话的简化过程

(1) 客户端发送可供选择的加密方式,并向服务器请求证书
(2) 服务器端发送证书以及选定的加密方式给客户端
(3) 客户端取得证书并进行证书验证
如果信任给其发证书的CA
(a) 验证证书来源的合法性;用CA的公钥解密证书上数字签名
(b) 验证证书的内容的合法性:完整性验证
(c) 检查证书的有效期限
(d) 检查证书是否被吊销
(e) 证书中拥有者的名字,与访问的目标主机要一致
(4) 客户端生成临时会话密钥(对称密钥),并使用服务器端的公钥加密
此数据发送给服务器,完成密钥交换
(5) 服务用此密钥加密用户请求的资源,响应给客户端
 注意:SSL是基于IP地址实现,单IP的主机仅可以使用一个https虚拟主机

2.https实现

(1) 为服务器申请数字证书

测试:通过私建CA发证书
(a) 创建私有CA
(b) 在服务器创建证书签署请求
(c) CA签证

(2) 配置httpd支持使用ssl,及使用的证书

yum -y install mod_ssl
配置文件:/etc/httpd/conf.d/ssl.conf

DocumentRoot
ServerName
SSLCertificateFile
SSLCertificateKeyFile

(3) 测试基于https访问相应的主机

openssl s_client [-connect host:port] [-cert filename] [-CApath directory] [-CAfile filename]

3.http重定向https

 将http请求转发至https的URL
 重定向
Redirect [status] URL-path URL
 status状态:
 Permanent:Returns a permanent redirect status
(301) indicating that the resource has moved
permanently
 Temp:Returns a temporary redirect status (302).
This is the default
 示例:
Redirect temp / https://www.magedu.com/

4.HSTS

HSTS:HTTP Strict Transport Security

服务器端配置支持HSTS后,会在给浏览器返回的HTTP首部中携带
HSTS字段。浏览器获取到该信息后,会将所有HTTP访问请求在内部
做307跳转到HTTPS。而无需任何网络过程

HSTS preload list

是Chrome浏览器中的HSTS预载入列表,在该列表中的网站,使用
Chrome浏览器访问时,会自动转换成HTTPS。Firefox、Safari、
Edge浏览器也会采用这个列表

实现HSTS示例:

vim /etc/httpd/conf/httpd.conf
Header always set Strict-Transport-Security "maxage=15768000"
RewriteEngine on
RewriteRule ^(/.*)$ https://%{HTTP_HOST}$1 [redirect=301]

5.httpd自带的工具程序

htpasswd:basic认证基于文件实现时,用到的账号密码文件
生成工具
apachectl:httpd自带的服务控制脚本,支持start和stop
apxs:httpd-devel包提供,扩展httpd使用第三方模块工具
rotatelogs:日志滚动工具
access.log -->
access.log, access.1.log -->
access.log, acccess.1.log, access.2.log
suexec:访问某些有特殊权限配置的资源时,临时切换至指
定用户身份运行

6. httpd的压力测试工具

 ab, webbench, http_load, seige
 Jmeter 开源
 Loadrunner 商业,有相关认证
 tcpcopy:网易,复制生产环境中的真实请求,并将之保存

ab [OPTIONS] URL

来自httpd-tools包
-n:总请求数
-c:模拟的并行数
-k:以持久连接模式测试

ulimit –n # 调整能打开的文件数

你可能感兴趣的:(https:http over ssl)