SNI stands for Server Name Indication, which is an extension of the TLS protocol. It is used to mark key client information during the TLS handshake. HTTPS often uses SNI to mark the request domain or hostname, allowing the webserver to quickly identify the request address, thereby implementing important features such as CDN, WAF, HTTP proxy, etc. (SNI is an extension of the TLS protocol, not only applicable to HTTP services but also can be used in non-HTTP services with TCP+TLS to achieve some specific functions.).
Once upon a time, when there was no SNI or the basic library did not support SNI, suppose we wanted to develop a web proxy, a basic function of the CDN or WAF system.
Each user system is connected to the web proxy system. Due to the lack of SNI support, for the proxy system to distinguish between multiple users, we naturally think of the following solutions:
Though the public network IP is limited, the first solution is not practical.
The second solution offers a poor user experience as the gateway where the HTTP client resides only opens ports 80/443, resulting in an inaccessible web.
The third solution is capable of executing some HTTP proxy functions and is a commonly used HTTP proxy solution. However, it struggles to implement some new features based on HTTPS.
Typically, CDN or WAF systems are not simply HTTP proxies, they also include the following basic features:
To implement the features above, when the web proxy receives an HTTP request, it must first determine the appropriate certificate to use for the handshake with the client. The successful completion of the handshake allows the HTTP content to be decrypted from TLS. This lies at the heart of the issue.
Because HTTPS is transmitted through TCP+TLS, the HTTP content received by the web proxy is encrypted data, and it is impossible to determine who sent the TCP connection. The web proxy has many user certificates, but which one should be used for the TLS handshake? What if every certificate is tried once? This is too inefficient! However, we found that although the content of TLS transmission is encrypted, the header of its message is plaintext (Hello message) during the handshake phase of establishing a session. If the client can place an ID that marks its own identity in the TLS handshake message, the problem will become very simple.
To solve scenarios like the above, a TLS extension has been implemented.
Web applications often use SNI to carry domain names or hostnames. In addition to the above-mentioned certificate loading, other functions can also be implemented. For example, when the user's SSL certificate cannot be obtained, the gateway only needs to scan TLS and SNI to implement domain name security checks, domain backup checks, etc. In addition, the Internet of Things can also use SNI to mark device IDs to implement two-way authentication of TLS.
In this rare case, the user may not be able to access certain websites, and the user's browser will return an error message such as "Your connection lacks security privacy."
The vast majority of browsers and operating systems support SNI. Only very old versions of Internet Explorer, old versions of the BlackBerry operating system, and other outdated software versions do not support SNI.
Currently, most browsers, HTTP servers, and their dependent encryption libraries support SNI. The following SNI support information comes from the Internet and is for reference only:
SNI is an extension of the SSL/TLS protocols, aimed at resolving the problem of decreasing IPv4 address availability. By incorporating the hostname that the client intends to connect to during the handshake process, the server can host multiple HTTPS-secured websites on the same IP address and TCP port number, each with its own unique SSL certificate.