SMTP TLS verification with OpenSSL
Check a real server’s TLS negotiation, certificate chain and hostname.
Choose the endpoint type
Use the hostname specified by the service owner and a current OpenSSL client with an appropriate trusted CA store. STARTTLS upgrades an SMTP connection. Implicit TLS begins encryption immediately. Select the method configured for the actual endpoint, rather than guessing from a failed attempt.
Run the appropriate command
STARTTLS
read -r -p "Actual SMTP certificate hostname: " smtp_host
read -r -p "SMTP port: " smtp_port
openssl s_client -starttls smtp -connect "$smtp_host:$smtp_port" \
-servername "$smtp_host" -verify_hostname "$smtp_host" \
-verify_return_error -showcerts </dev/nullImplicit TLS
read -r -p "Actual SMTP certificate hostname: " smtp_host
read -r -p "SMTP port: " smtp_port
openssl s_client -connect "$smtp_host:$smtp_port" \
-servername "$smtp_host" -verify_hostname "$smtp_host" \
-verify_return_error -showcerts </dev/nullThese commands connect and inspect the TLS session; they do not submit a message. The hostname is used for SNI and certificate identity verification. -verify_return_error makes verification errors terminate the handshake instead of merely being printed.
Read the result
- Check whether negotiation completed and whether certificate verification succeeded.
- Inspect the leaf certificate identity, validity dates and presented chain. A missing local trust store can also cause verification errors.
- Record the endpoint, port, client version and UTC time with the failure. Compare with the service’s documented certificate and chain configuration.
- After repair, repeat the same check from the relevant network path.
Inspect your local version
openssl version -aIf your client does not support an option, consult the matching OpenSSL manual and update through your normal package-management process.