commit 65fae6caab5201eca2d43143a7365f8c67efdf13 Author: Sam Napolitano Date: Thu Nov 9 20:18:49 2017 -0500 Strip trailing dot from certificate and hostname diff --git a/Lib/ssl.py b/Lib/ssl.py index 75caae0c44..c0493e4064 100644 --- a/Lib/ssl.py +++ b/Lib/ssl.py @@ -230,6 +230,12 @@ def _dnsname_match(dn, hostname, max_wildcards=1): if not dn: return False + # strip trailing dot + if dn[-1] == '.': + dn = dn[:-1] + if hostname[-1] == '.': + hostname = hostname[:-1] + leftmost, *remainder = dn.split(r'.') wildcards = leftmost.count('*')