Skip to content

Commit

Permalink
Allow to disable certificate validation
Browse files Browse the repository at this point in the history
  • Loading branch information
jjlawren committed Nov 7, 2019
1 parent b34a63e commit 6cde148
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions plexwebsocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,16 @@ def significant_position_change(self, timestamp, new_position):
class PlexWebsocket:
"""Represent a websocket connection to a Plex server."""

def __init__(self, plex_server, callback, session=None):
def __init__(self, plex_server, callback, session=None, verify_ssl=True):
"""Initialize a PlexWebsocket instance.
Parameters:
plex_server (plexapi.server.PlexServer):
A connected PlexServer instance.
callback (Runnable):
Callback to issue when Plex player events occur.
verify_ssl:
Set to False to disable SSL certificate validation.
session (aiohttp.ClientSession, optional):
Provide an optional session object.
Expand All @@ -51,6 +53,7 @@ def __init__(self, plex_server, callback, session=None):
self.callback = callback
self._active = True
self._current_task = None
self._ssl = False if verify_ssl is False else None

@staticmethod
def _get_uri(plex_server):
Expand All @@ -64,7 +67,7 @@ async def listen(self):
self._active = True
while self._active:
try:
async with self.session.ws_connect(self.uri, heartbeat=15) as ws_client:
async with self.session.ws_connect(self.uri, heartbeat=15, ssl=self._ssl) as ws_client:
self._current_task = asyncio.Task.current_task()
_LOGGER.debug("Websocket connected")
self.callback()
Expand Down

0 comments on commit 6cde148

Please sign in to comment.