HTTPS is now widely used. While it brings security, it also introduces more complex concepts to the Web, including a series of network protocols that have never been seen before. Now Harttle starts from the principle of HTTPS and tries to interpret these protocols involved in HTTPS in the most popular way. HTTPS Overview HTTPS is HTTP built on secure communication, using transport layer encryption (TLS or SSL). Its purpose is to protect user privacy (such as preventing HTTP content from being intercepted by network nodes) and data integrity (such as operators inserting advertisements), that is, end-to-end encryption to prevent man-in-the-middle attacks. TLS/SSL is a protocol above the transport layer and below the application layer, so the content of the HTTP protocol is not affected. These encryptions use asymmetric encryption algorithms, so an official is needed to publish the public key, which is the key infrastructure (CA). Therefore, each browser will have some CA root certificates built in, and these CAs can further authorize other domain names, so that your browser can authenticate the domain name you are visiting. If you want your own service to support HTTPS, you can register your own domain name with a CA. There are some free CAs such as GoDaddy, Let's Encrypt, CloudFlare, etc. HTTPS interaction example The following Wireshark log records a GET request sent to https://github.com/harttle, showing the interaction process of several major protocols:
TLS/SSL TLS is formerly known as SSL, which runs on top of TCP in the TCP/IP protocol stack and is used to exchange keys and form an encryption layer (Record Layer). TLS is the core protocol of HTTPS, and the main difference between HTTPS interaction and HTTP interaction lies in this layer: Before starting to transmit ciphertext, it is necessary to exchange keys, verify the server certificate and other preparations. Therefore, TLS also has a handshake phase. The main steps are: the client sends ClientHello, the server sends ServerHello, the server continues to send Certificate, and then send KeyExchange messages to each other, and finally send ChangeCipherSpec to notify the other party that the subsequent transmission is ciphertext. For specific interactions and protocol fields, please refer to RFC 5246 (TLSv1.2) and RFC 6176 (TLSv2.0). TLS is a widely used encryption protocol in the TCP/IP protocol stack. RFC 4366 - TLS Extensions is defined to support protocol extensions of common mechanisms. TLS has been adopted by mail services, web services, FTP, etc. Here is a list of extended protocols. This article focuses on extensions related to Web services (HTTPS), such as SNI, NPN, and ALPN. These protocols add new features to TLS by extending the TLS ClientHello/ServerHello messages. To this end, let's first look at the structure of the ClientHello message (ServerHello is similar):
Note the last field, there can be up to 65536 extensions, where an extension is defined as a two-byte ExtensionType and the corresponding opaque data. The following SNI, NPN, and ALPN are all one of them. SNI SNI (Server Name Indication) specifies the host name to connect to during the TLS handshake. The SNI protocol is designed to support multiple domain names for the same IP (and port). Because during the TLS handshake, the server needs to send a certificate to the client, and for this it needs to know the domain name requested by the client (because the certificates for different domain names may be different). At this time, some students will ask, isn’t the host name to be connected the same as the Host when initiating HTTP? This is a misunderstanding of the HTTPS mechanism. When the TLS Handshake occurs, the HTTP interaction has not yet begun, so naturally the HTTP header has not yet reached the server. The SNI protocol is defined in RFC 6066:
Let's look at the example at the beginning of this article, the SNI Extension field in the ClientHello sent to github.com in line 4:
ALPN/NPN ALPN (Application-Layer Protocol Negotiation) is also an extension of the TLS layer, used to negotiate the protocol used by the application layer. Its predecessor was NPN, which was originally used to support the Google SPDY protocol (now standardized as HTTP/2). Problems with TLS client and server versions have caused a lot of pain in the switching process from SPDY->HTTP/2 and NPN->ALPN:
Therefore, it has become a consensus of today's Web platform to promote Web infrastructure in a standard-first way. We are not talking about those (quasi) browser manufacturers who are still engaged in workshop-style production. Any implementation that blocks the development of the Web platform (even standards, such as XHTML, OSI...) will be eliminated sooner or later. Back to the topic, ALPN is defined in RFC 7301 - Transport Layer Security (TLS) Application-Layer Protocol Negotiation Extension.
Let's look at the example at the beginning of this article, the ALPN Extension field in the ClientHello sent to github.com in line 4:
The message body of Extension contains multiple strings (protocol_name_list), which represent all application layer protocols supported by the client. In the above example, there are two protocols: h2 and http/1.1. Clients that support SPDY will have an additional spdy/2. You need to select one of them in the ServerHello given by the server. In the example in this article, the ALPN field of ServerHello is:
In this way, the Server and Client have reached a consensus using the ALPN protocol and will communicate using the HTTP/1.1 protocol after the handshake is completed. References and Acknowledgements Starting from TLS, the key layer of HTTPS, a typical HTTPS interaction process is introduced. Combined with the byte sequence given by the packet capture, the principles and main contents of TLS, SNI, ALPN and other protocols are introduced in turn. |
<<: AI and IoT are still popular, but they still rely on big data analysis
>>: 5G will make your 4G mobile phone obsolete. How can you become a "pig" in the 5G trend?
DesiVPS has just sent out the latest promotional ...
While the new infrastructure is accelerating the ...
Friendhosting released this year's Black Frid...
2020-12-31 09:392020 is a year of vigorous constr...
This year is a period of large-scale 5G construct...
At the "2020 Network 5.0 Summit", when ...
spinservers sent a new promotional information. A...
In order to respond to public concerns, People...
[[432368]] This year's 11.11 Shopping Festiva...
[[384427]] This article intends to discuss gatewa...
The epidemic has interrupted the construction pro...
[[177286]] It is reported that my country will la...
The latest data from the Ministry of Industry and...
TmhHost recently launched a summer promotion, wit...
Editor’s Note: The Chongqing Local Taxation Burea...