本篇内容介绍了“TLS握手过程是怎样的”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
TLS 握手的详细过程可参考下图:
从 wireshark
抓包,也可以看到握手的详细流程,建议抓包加强理解,以下是抓包 https://q.shanyue.tech
时的握手流程
通过 curl -vvv --head
来查看握手信息:
$ curl -vvv --head https://q.shanyue.tech
* Trying 111.6.180.235...
* TCP_NODELAY set
* Connected to q.shanyue.tech (111.6.180.235) port 443 (#0)
* ALPN, offering h3
* ALPN, offering http/1.1
* successfully set certificate verify locations:
* CAfile: /etc/ssl/cert.pem
CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN, server accepted to use h3
* Server certificate:
* subject: CN=q.shanyue.tech
* start date: Dec 2 00:00:00 2019 GMT
* expire date: Dec 1 12:00:00 2020 GMT
* subjectAltName: host "q.shanyue.tech" matched cert's "q.shanyue.tech"
* issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=Encryption Everywhere DV TLS CA - G1
* SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x7f95ba80dc00)
握手过程
-
[OUT] Client Hello,客户端选出自己支持的 TLS 版本号、
cipher suites
以及一个随机数给服务器端 -
[IN] Server Hello,服务器端选出双方都支持的 TLS 版本,
cipher suite
以及一个随机数给服务端 -
[IN] Certificate,服务器端给客户端发送证书,用以验证合法性及提供公钥 -
[IN] Server Key Exchange,服务器端给客户端发送 DH 秘钥交换算法的一些参数 -
[IN] Server Finished -
[OUT] Client Key Exchange,客户端给服务器端发送 DH 公钥,并计算出对称加密中的公钥 -
[OUT] Change Cipher Spec,告知对方以后的消息将要使用TLS记录层协议进行加密 -
[OUT] Finished,发送第一条加密的消息 -
[IN] Change Cipher Spec,告知以后的消息将要使用TLS记录层协议进行加密 -
[IN] Finished,发送第一条加密的消息
“TLS握手过程是怎样的”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注亿速云网站,小编将为大家输出更多高质量的实用文章!
原创文章,作者:kirin,如若转载,请注明出处:https://blog.ytso.com/219909.html