You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since bpo bpo-23033, ssl.match_hostname() no longer supports partial wildcard matching, e.g. "www*.example.org". In case of a partial match, _dnsname_match() fails with a confusing/wrong error message:
>>> import ssl
>>> ssl._dnsname_match('www*.example.com', 'www1.example.com')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File ".../cpython/Lib/ssl.py", line 198, in _dnsname_match
"wildcard can only be present in the leftmost segment: " + repr(dn))
ssl.SSLCertVerificationError: ("wildcard can only be present in the leftmost segment: 'www*.example.com'",)
The wildcard *is* in the leftmost segment. But it's not a full match but a partial match.
The error message applies to a SAN dNSName like "*.*.example.org" or "www.*.example.com", however the function does not raise an error for multiple or non left-most wildcards:
# multiple wildcards return None
>>> ssl._dnsname_match('*.*.example.com', 'www.sub.example.com')
# single wildcard in another label returns False
>>> ssl._dnsname_match('www.*.example.com', 'www.sub.example.com')
False
New changeset 46632f4 by Christian Heimes (Miss Islington (bot)) in branch '3.7':
[3.7] bpo-32819: Simplify and improve ssl.match_hostname (GH-5620) (bpo-5847) 46632f4
Should I backport the issue to 2.7 and 3.6, too? It changes behavior slightly because it drops support for partial wildcards. RFC 6125 consider it an optional feature. AFAIK browsers don't match them either.
Activity
tiran commentedon Feb 11, 2018
Since bpo bpo-23033, ssl.match_hostname() no longer supports partial wildcard matching, e.g. "www*.example.org". In case of a partial match, _dnsname_match() fails with a confusing/wrong error message:
The wildcard *is* in the leftmost segment. But it's not a full match but a partial match.
The error message applies to a SAN dNSName like "*.*.example.org" or "www.*.example.com", however the function does not raise an error for multiple or non left-most wildcards:
tiran commentedon Feb 24, 2018
New changeset aef1283 by Christian Heimes in branch 'master':
bpo-32819: Simplify and improve ssl.match_hostname (bpo-5620)
aef1283
tiran commentedon Feb 24, 2018
New changeset 46632f4 by Christian Heimes (Miss Islington (bot)) in branch '3.7':
[3.7] bpo-32819: Simplify and improve ssl.match_hostname (GH-5620) (bpo-5847)
46632f4
tiran commentedon Feb 24, 2018
master and 3.7 are fixed.
Should I backport the issue to 2.7 and 3.6, too? It changes behavior slightly because it drops support for partial wildcards. RFC 6125 consider it an optional feature. AFAIK browsers don't match them either.
alex commentedon Feb 24, 2018
Can confirm, no browsers do partial (or multiple) wildcards and the CABF rules don't allow public CAs to issue them.
alex commentedon Feb 24, 2018
(Didn't mean to update status)
tiran commentedon Feb 24, 2018
Don't worry, it happens automatically when somebody replies to a pending ticket w/o closing it explicitly.
I need to backport the patch manually.
tiran commentedon Feb 24, 2018
I also fixed an issue for Brandon's backport, https://bitbucket.org/brandon/backports.ssl_match_hostname/issues/12/update-to-implementation-from-37