Correctly detect whether we can use SSL to connect to the PMS
This commit is contained in:
parent
310ae54e7b
commit
a1bda39e9d
1 changed files with 21 additions and 18 deletions
|
@ -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):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue