Skip to content

httpclient: a certificate for ww*.example.com fails verification for www.example.com instead of matching it - #356

Merged
MDA2AV merged 1 commit into
mainfrom
fix/342-no-partial-wildcards
Oct 13, 2026
Merged

MDA2AV merged 1 commit into
mainfrom
fix/342-no-partial-wildcards

Conversation

@MDA2AV

@MDA2AV MDA2AV commented Oct 12, 2026 •

Copy link
Copy Markdown
Owner

Fixes #342.

The TLS client accepted a certificate for ww*.example.com when connecting to www.example.com. SSL_set1_host ran with OpenSSL's default host flags, and those let a partial wildcard match.

ConfigureNames now calls SSL_set_hostflags(ssl, X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS) right after SSL_set1_host. curl sets the same flag, and SslStream and Python refuse partial wildcards outright. It is one call per connection, on the SSL the name is set on. With VerifyCertificate = false no name is set, so the flag has nothing to act on. Nothing else changes: a full wildcard (*.example.com) still matches one label, and still not two.

Proof

The pending test tls client: a partial wildcard must not match (ww*.example.com is not www.example.com) is now a Test().

Http suite
the promoted test, with the src/ change reverted FAIL ... a partial wildcard should not have authenticated www.example.com, got: 200|verified - 83 passed, 1 failed, 3 pending
with the fix PASS - 84 passed, 0 failed, 3 pending

Its two controls, control - a full wildcard matches one label below it and a wildcard does not match across a label, pass both ways. The 3 pending are #343, #340 and #344's tests, as on main (main: 83 passed, 4 pending).

With its siblings

This batch is #356 (#342), #358 (#343), #366 (#344) and #370 (#340). They merge with each other without conflicts, checked pairwise and all four together. #358 and #366 both edit RunHandshakeAsync, in separate hunks. With all four merged, the Http suite is 88 passed, 0 failed, 0 pending.

…ww.example.com instead of matching it

SSL_set1_host ran with OpenSSL's default host flags, which let a partial wildcard match: a
certificate for 'ww*.example.com' authenticated 'www.example.com'. The client now sets
X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS on each SSL after SSL_set1_host, as curl does; SslStream
and Python refuse partial wildcards outright. A full wildcard ('*.example.com') still matches one
label, and still not two.

The pending test "tls client: a partial wildcard must not match (ww*.example.com is not
www.example.com)" is now a Test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tls client: a partial wildcard certificate (ww*.example.com) matches www.example.com

1 participant