restrict to *. only, add DN support also

This commit is contained in:
neocogent 2015-07-17 10:48:28 +07:00
parent 3c563b85ad
commit 8792301846
1 changed files with 2 additions and 2 deletions

View File

@ -128,7 +128,7 @@ class TcpInterface(threading.Thread):
return False
if peercert.has_key("subjectAltName"):
for typ, val in peercert["subjectAltName"]:
if typ == "DNS" and (val == name or (val[0] == '*' and name.find(val[1:]) + len(val[1:]) == len(name))):
if typ == "DNS" and (val == name or (val.find('*.') == 0 and name.find(val[1:]) + len(val[1:]) == len(name))):
return True
else:
# Only check the subject DN if there is no subject alternative
@ -139,7 +139,7 @@ class TcpInterface(threading.Thread):
if attr == "commonName":
cn = val
if cn is not None:
return cn == name
return (cn == name or (cn.find('*.') == 0 and name.find(cn[1:]) + len(cn[1:]) == len(name)))
return False