mirror of
https://github.com/moepman/acertmgr.git
synced 2024-12-29 11:31:49 +01:00
tools: Fix IDNA handler (again)
This commit is contained in:
parent
b37d0cad94
commit
0648cb7b38
@ -375,24 +375,24 @@ def target_is_current(target, file):
|
|||||||
|
|
||||||
# @brief convert domain list to idna representation (if applicable
|
# @brief convert domain list to idna representation (if applicable
|
||||||
def idna_convert(domainlist):
|
def idna_convert(domainlist):
|
||||||
if 'idna' in sys.modules and any(ord(c) >= 128 for c in ''.join(domainlist)):
|
if any(ord(c) >= 128 for c in ''.join(domainlist)):
|
||||||
domaintranslation = list()
|
try:
|
||||||
for domain in domainlist:
|
domaintranslation = list()
|
||||||
if any(ord(c) >= 128 for c in domain):
|
for domain in domainlist:
|
||||||
# Translate IDNA domain name from a unicode domain (handle wildcards separately)
|
if any(ord(c) >= 128 for c in domain):
|
||||||
if domain.startswith('*.'):
|
# Translate IDNA domain name from a unicode domain (handle wildcards separately)
|
||||||
idna_domain = "*.{}".format(domain[2:].encode('idna').decode('ascii'))
|
if domain.startswith('*.'):
|
||||||
|
idna_domain = "*.{}".format(domain[2:].encode('idna').decode('ascii'))
|
||||||
|
else:
|
||||||
|
idna_domain = domain.encode('idna').decode('ascii')
|
||||||
|
result = idna_domain, domain
|
||||||
else:
|
else:
|
||||||
idna_domain = domain.encode('idna').decode('ascii')
|
result = domain, domain
|
||||||
result = idna_domain, domain
|
domaintranslation.append(result)
|
||||||
else:
|
return domaintranslation
|
||||||
result = domain, domain
|
except Exception as e:
|
||||||
domaintranslation.append(result)
|
log("Unicode domain(s) found but IDNA names could not be translated due to error: {}".format(e), error=True)
|
||||||
return domaintranslation
|
return [(x, x) for x in domainlist]
|
||||||
else:
|
|
||||||
if any(ord(c) >= 128 for c in ''.join(domainlist)) and 'idna' not in sys.modules:
|
|
||||||
log("Unicode domain(s) found but IDNA names could not be translated due to missing idna module", error=True)
|
|
||||||
return [(x, x) for x in domainlist]
|
|
||||||
|
|
||||||
|
|
||||||
# @brief validate the OCSP status for a given certificate by the given issuer
|
# @brief validate the OCSP status for a given certificate by the given issuer
|
||||||
|
Loading…
Reference in New Issue
Block a user