mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-12 08:16:06 -07:00
Allow SSL cert verify override on Plex.tv requests.
This commit is contained in:
parent
2c77f2df98
commit
d345893529
2 changed files with 13 additions and 4 deletions
|
@ -18,16 +18,18 @@ from plexpy import logger, helpers
|
||||||
from httplib import HTTPSConnection
|
from httplib import HTTPSConnection
|
||||||
from httplib import HTTPConnection
|
from httplib import HTTPConnection
|
||||||
|
|
||||||
|
import ssl
|
||||||
|
|
||||||
class HTTPHandler(object):
|
class HTTPHandler(object):
|
||||||
"""
|
"""
|
||||||
Retrieve data from Plex Server
|
Retrieve data from Plex Server
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, host, port, token):
|
def __init__(self, host, port, token, ssl_verify=True):
|
||||||
self.host = host
|
self.host = host
|
||||||
self.port = str(port)
|
self.port = str(port)
|
||||||
self.token = token
|
self.token = token
|
||||||
|
self.ssl_verify = ssl_verify
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Handle the HTTP requests.
|
Handle the HTTP requests.
|
||||||
|
@ -50,9 +52,14 @@ class HTTPHandler(object):
|
||||||
|
|
||||||
if uri:
|
if uri:
|
||||||
if proto.upper() == 'HTTPS':
|
if proto.upper() == 'HTTPS':
|
||||||
handler = HTTPSConnection(self.host, self.port, timeout=10)
|
if not self.ssl_verify:
|
||||||
|
context = ssl._create_unverified_context()
|
||||||
|
handler = HTTPSConnection(host=self.host, port=self.port, timeout=10, context=context)
|
||||||
|
logger.warn(u"PlexPy HTTP Handler :: Unverified HTTPS request made. This connection is not secure.")
|
||||||
else:
|
else:
|
||||||
handler = HTTPConnection(self.host, self.port, timeout=10)
|
handler = HTTPSConnection(host=self.host, port=self.port, timeout=10)
|
||||||
|
else:
|
||||||
|
handler = HTTPConnection(host=self.host, port=self.port, timeout=10)
|
||||||
|
|
||||||
token_string = ''
|
token_string = ''
|
||||||
if not no_token:
|
if not no_token:
|
||||||
|
|
|
@ -89,10 +89,12 @@ class PlexTV(object):
|
||||||
self.protocol = 'HTTPS'
|
self.protocol = 'HTTPS'
|
||||||
self.username = username
|
self.username = username
|
||||||
self.password = password
|
self.password = password
|
||||||
|
self.ssl_verify = plexpy.CONFIG.VERIFY_SSL_CERT
|
||||||
|
|
||||||
self.request_handler = http_handler.HTTPHandler(host='plex.tv',
|
self.request_handler = http_handler.HTTPHandler(host='plex.tv',
|
||||||
port=443,
|
port=443,
|
||||||
token=plexpy.CONFIG.PMS_TOKEN)
|
token=plexpy.CONFIG.PMS_TOKEN,
|
||||||
|
ssl_verify=self.ssl_verify)
|
||||||
|
|
||||||
def get_plex_auth(self, output_format='raw'):
|
def get_plex_auth(self, output_format='raw'):
|
||||||
uri = '/users/sign_in.xml'
|
uri = '/users/sign_in.xml'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue