1、證書生成。html
一、SSL Server生成私鑰/公鑰對。server.key(加密)/server.pub(解密);
二、server.pub生成請求文件server.csr,包含server的一些信息,如域名/申請者/公鑰等;
三、server將server.csr遞交給CA,CA驗證經過,用ca.key和csr加密生成server.cert;
四、server將證書server.cert傳給client,client經過ca.crt解密server.cert。nginx
附證書製做流程:https://m.aliyun.com/yunqi/articles/40398算法
2、認證交互json
3、SSL認證數據包分析session
1、客戶端請求包app
版本信息:測試
隨機數:加密
加密套件列表:url
壓縮算法和擴展參數:spa
2、服務端響應包:
版本號:
隨機數:
選擇的加密套件,壓縮算法,及擴展參數:
證書:
3、客戶端隨機數包
4、通知祕鑰和加密算法
5、握手驗證消息
6、通知客戶端加密算法與握手限制消息
7、加密通訊(3)
8、Encrypted Alert,SSL告警,這裏出現一般是提示SSL傳輸完成
4、nginx代理證書配置(附測試腳本)
server { listen 8000 ssl; listen[::]:8000 ssl; server_name *.*.*.*:8000; ssl on; ssl_certificate /home/nginx/conf/cert/ server.cert; ssl_certificate_key /home/nginx/conf/cert/server.key; ssl_client_certificate /home/nginx/conf/cert/ca.cert; ssl_verify_client on; ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; ssl_protocols TLSv1.2; ssl_ciphers ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256; ssl_prefer_server_ciphers on; error_log /var/log/nginx/error.log error; location / { proxy_ssl_certificate /home/nginx/conf/cert/client.cert; proxy_ssl_certificate_key /home/nginx/conf/cert/client.key; proxy_ssl_trusted_certificate /home/nginx/conf/cert/ca.cert; proxy_ssl_verify on;
proxy_ssl_session_reuse on; proxy_pass https://*.*.*.*:8080; } }
關於其餘參數請參見:http://nginx.org/en/docs/http/ngx_http_proxy_module.html
import httplib2 ca_cert = '/home/nginx/conf/cert/client/ca.cert' client_key = '/home/nginx/conf/cert/client/client.key' client_cert = '/home/nginx/conf/cert/client/client.cert' full_url = 'https://*.*.*.*:8000/test_url' headers = { 'content-type': 'application/json', 'accept': 'application/json' } http = httplib2.Http(timeout=120, ca_certs=ca_cert, disable_ssl_certificate_validation=False) http.follow_all_redirects = True http.add_certificate(client_key, client_cert, '') resp, resp_content = http.request(full_url, method='GET', headers=headers) print resp, resp_content