add option to verify HTTPS certificate

This commit is contained in:
sfaulds 2017-06-23 09:55:28 +10:00
parent 088b686a62
commit ddd68ae5ea
4 changed files with 16 additions and 3 deletions

View File

@ -22,6 +22,10 @@ msgctxt "#30002"
msgid "Use HTTPS: "
msgstr ""
msgctxt "#30003"
msgid "Verify HTTPS Certificate: "
msgstr ""
msgctxt "#30004"
msgid "Log Level: "
msgstr ""

View File

@ -312,10 +312,16 @@ class DownloadUtils():
settings = xbmcaddon.Addon('plugin.video.embycon')
use_https = settings.getSetting('use_https') == 'true'
verify_cert = settings.getSetting('verify_cert') == 'true'
if use_https:
if use_https and verify_cert:
log.debug("Connection: HTTPS, Cert checked")
conn = httplib.HTTPSConnection(server, timeout=40)
elif use_https and not verify_cert:
log.debug("Connection: HTTPS, Cert NOT checked")
conn = httplib.HTTPSConnection(server, timeout=40, context=ssl._create_unverified_context())
else:
log.debug("Connection: HTTP")
conn = httplib.HTTPConnection(server, timeout=40)
head = self.getAuthHeader(authenticate)
@ -377,9 +383,9 @@ class DownloadUtils():
log.error(error)
if suppress is False:
if popup == 0:
xbmc.executebuiltin("Notification(%s, %s)" % (self.addon_name, i18n('url_error_') % i18n('unable_connect_server')))
xbmc.executebuiltin("Notification(%s, %s)" % (self.addon_name, i18n('url_error_') % str(msg)))
else:
xbmcgui.Dialog().ok(self.addon_name, i18n('url_error_') % i18n('unable_connect_server'))
xbmcgui.Dialog().ok(self.addon_name, i18n('url_error_') % i18n('unable_connect_server'), str(msg))
#raise
finally:
try:

View File

@ -181,6 +181,8 @@ def getCollections(detailsString):
log.debug("jsonData : " + jsonData)
result = json.loads(jsonData)
if result is None:
return []
parentid = result.get("Id")
log.info("parentid : " + parentid)

View File

@ -4,6 +4,7 @@
<setting id="ipaddress" type="text" label="30000" default="&lt;none&gt;" visible="true" enable="true" />
<setting id="port" type="text" label="30001" default="8096" visible="true" enable="true" />
<setting id="use_https" type="bool" label="30002" default="false" visible="true" enable="true" />
<setting id="verify_cert" type="bool" label="30003" default="false" visible="true" enable="true" />
<setting label="30011" type="action" action="RunScript(plugin.video.embycon,0,?mode=DETECT_SERVER_USER)" option="close"/>
<setting type="sep" />
<setting id="username" type="text" label="30024" />