Use cURL with SNI (Server Name Indication)

Server Name Indication (SNI) is an extension to the Transport Layer Security (TLS) protocol that allows a client to specify the hostname it is trying to connect to at the start of the handshaking process. This is useful when a server is hosting multiple websites on the same IP address, as it allows the server to present the correct SSL/TLS certificate for the hostname the client is trying to reach.

cURL is a command-line tool that can be used to make various types of HTTP requests, including HTTPS requests. By default, cURL will use SNI when making HTTPS requests, so no special options are needed to enable it.

Here is an example of using cURL to make an HTTPS request to a website that uses SNI:


You could also use the -v option to get more detailed information about the request, which will show the SNI extension in the SSL/TLS handshake:

curl -v

You can also use the --resolve option to set the SNI hostname explicitly when making the request:

curl --resolve

This tells cURL to use the IP address for the hostname when making the request, and to use the hostname in the SNI extension.