openssl Verified current stable Not installed? Security

Openssl / Set Sni Connection

Set Sni Connection

Initiates an SNI-enabled connection to a specified server and port.

$
Terminal
openssl s_client -connect <host>:<port> -servername <hostname>

When To Use

When querying servers hosting multiple domains on a single IP address

Pro Tip

Specify the correct hostname using '-servername' to avoid incorrect certificate retrieval.

Command Builder

Tune the command before you copy it

Back to syntax
$
Generated Command
openssl s_client -connect <host>:<port> -servername <hostname>

Anatomy of Output

Understanding the result

CONNECTED(00000003) Connection Status

Indicates successful connection to the specified server.

Certificate chain 0 s: /C=US/ST=California/L=San Francisco/O=Example Co/CN=example.com Certificate Details

Displays details of the returned certificate.

Troubleshooting

Common pitfalls

unable to connect

Solution: Verify host and port are correct and accessible.

SSL routines:ssl23_get_server_hello:wrong version number

Solution: Ensure the correct protocol version is being used.

SNI not supported

Solution: Verify the OpenSSL version supports SNI.

Command Breakdown

What each part is doing

openssl
Base Command
The executable that performs this operation. Here it runs Openssl before the shell applies any redirect operators.
<host>
host
The host or server name supplied to this command.
<port>
port
The port value supplied to this command.
<hostname>
hostname
The host or server name supplied to this command.
-connect
Command Option
Tool-specific option used by this command invocation.
-servername
Command Option
Tool-specific option used by this command invocation.

Alternative Approaches

Comparable commands in other tools

Alternative security tools for the same job.