tool-openssl/s_client: default SNI to -connect host to match OpenSSL#3209
Open
tool-openssl/s_client: default SNI to -connect host to match OpenSSL#3209
Conversation
aws-lc's openssl s_client tool does not send the SNI extension unless the user explicitly passes -servername. OpenSSL's s_client has defaulted SNI to the -connect hostname since OpenSSL 1.1, with a DNS-name check that suppresses SNI for IP literals (RFC 6066 section 3 forbids SNI for IPs), and exposes -noservername as an explicit opt-out. This change brings aws-lc's is_openssl_s_client path in line with that behavior: - Default SNI to the hostname parsed from -connect when neither -servername/-server-name nor -noservername was provided. - Skip the default for IP literals and single-label hostnames via a verbatim port of OpenSSL's is_dNS_name helper. - Add -noservername as an opt-out flag, with the same mutual-exclusion error message as OpenSSL when combined with -servername. The is_dNS_name helper is copied verbatim from OpenSSL 3.x apps/s_client.c (commit 653f437c2a, file lines 3847-3910) and carries an Apache-2.0 attribution header matching the style used elsewhere in aws-lc (e.g. tool-openssl/txt_db/txt_db.cc). The bssl client tool (is_openssl_s_client == false) is unaffected.
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3209 +/- ##
==========================================
+ Coverage 78.12% 78.27% +0.15%
==========================================
Files 689 689
Lines 122951 123006 +55
Branches 17107 17124 +17
==========================================
+ Hits 96056 96288 +232
+ Misses 25992 25805 -187
- Partials 903 913 +10 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
WillChilds-Klein
previously approved these changes
May 4, 2026
WillChilds-Klein
approved these changes
May 6, 2026
samuel40791765
approved these changes
May 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of changes:
aws-lc's
openssl s_clienttool does not send the SNI extension unless the user explicitly passes-servername. OpenSSL'ss_clienthas defaulted SNI to the-connecthostname since OpenSSL 1.1, with a DNS-name check that suppresses SNI for IP literals (RFC 6066 §3 forbids SNI for IPs), and exposes-noservernameas an explicit opt-out.This PR brings aws-lc's
is_openssl_s_clientcode path in line with that behavior:-connectwhen neither-servername/-server-namenor-noservernamewas provided.is_dNS_namehelper.-noservernameas an opt-out flag, with the same mutual-exclusion error message as OpenSSL when combined with-servername.The
bssl clienttool (is_openssl_s_client == false) is unaffected.Call-outs:
The
is_dNS_namehelper intool/client.ccis copied verbatim from OpenSSL 3.xapps/s_client.c(commit653f437c2a, file lines 3847–3910) and carries an Apache-2.0 attribution header matching the style used elsewhere in aws-lc (e.g.tool-openssl/txt_db/txt_db.cc,generated-src/*). Please flag any aws-lc conventions I should match more closely for this kind of verbatim third-party copy.Behavior change visible to CLI users:
./openssl s_client -connect foo.com:443foo.com./openssl s_client -connect foo.com:443 -servername bar.combar.com./openssl s_client -connect foo.com:443 -noservername./openssl s_client -connect 1.2.3.4:443./openssl s_client -connect [::1]:443./openssl s_client -connect localhost:443By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.