Correctly detect whether we can use SSL to connect to the PMS

This commit is contained in:
croneter 2020-02-21 08:22:09 +01:00
parent 310ae54e7b
commit a1bda39e9d

View file

@ -846,28 +846,31 @@ def _pms_https_enabled(url):
Prefers HTTPS over HTTP Prefers HTTPS over HTTP
""" """
res = DU().downloadUrl('https://%s/identity' % url, # Try HTTPS first
authenticate=False,
verifySSL=True if v.KODIVERSION >= 18 else False)
try: try:
res.attrib DU().downloadUrl('https://%s/identity' % url,
except AttributeError: authenticate=False,
# Might have SSL deactivated. Try with http reraise=True)
res = DU().downloadUrl('http://%s/identity' % url, except exceptions.SSLError:
authenticate=False, LOG.debug('SSLError trying to connect to https://%s/identity', url)
verifySSL=True if v.KODIVERSION >= 18 else False) except Exception as e:
try: LOG.info('Couldnt check https connection to https://%s/identity: %s',
res.attrib url, e)
except AttributeError:
LOG.error("Could not contact PMS %s", url)
return None
else:
# Received a valid XML. Server wants to talk HTTP
return False
else: else:
# Received a valid XML. Server wants to talk HTTPS
return True return True
# Try HTTP next
try:
DU().downloadUrl('http://%s/identity' % url,
authenticate=False,
reraise=True)
except Exception as e:
LOG.info('Couldnt check http connection to http://%s/identity: %s',
url, e)
return
else:
return False
def GetMachineIdentifier(url): def GetMachineIdentifier(url):
""" """