Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plex sensor not working when using username/password #11581

Closed
arsaboo opened this issue Jan 11, 2018 · 4 comments · Fixed by #13005
Closed

Plex sensor not working when using username/password #11581

arsaboo opened this issue Jan 11, 2018 · 4 comments · Fixed by #13005

Comments

@arsaboo
Copy link
Contributor

arsaboo commented Jan 11, 2018

Home Assistant release (hass --version): 0.60.1

Python release (python3 --version): 3.6.2

Component/platform: Plex Sensor

Description of problem: Looks like it is an upstream issue, but leaving the issue open for others until it is fixed. Also, only those using username/password will be affected. See the logs below.

2018-01-11 15:57:28 ERROR (SyncWorker_32) [urllib3.connection] Certificate did not match expected hostname: my.plexapp.com. Certificate: {'subject': ((('businessCategory', 'Private Organization'),), (('jurisdictionCountryName', 'CH'),), (('serialNumber', 'CH15040047209'),), (('countryName', 'CH'),), (('localityName', 'Stans'),), (('organizationName', 'Plex GmbH'),), (('commonName', 'plex.tv'),)), 'issuer': ((('countryName', 'US'),), (('organizationName', 'DigiCert Inc'),), (('organizationalUnitName', 'www.digicert.com'),), (('commonName', 'DigiCert SHA2 Extended Validation Server CA'),)), 'version': 3, 'serialNumber': '07AC7078181A3691747A52E310A90002', 'notBefore': 'Dec 15 00:00:00 2017 GMT', 'notAfter': 'Dec 19 12:00:00 2019 GMT', 'subjectAltName': (('DNS', 'plex.tv'), ('DNS', 'www.plex.tv')), 'OCSP': ('http://ocsp.digicert.com',), 'caIssuers': ('http://cacerts.digicert.com/DigiCertSHA2ExtendedValidationServerCA.crt',), 'crlDistributionPoints': ('http://crl3.digicert.com/sha2-ev-server-g2.crl', 'http://crl4.digicert.com/sha2-ev-server-g2.crl')}
2018-01-11 15:57:28 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform plex
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.6/site-packages/urllib3/connectionpool.py", line 601, in urlopen
    chunked=chunked)
  File "/srv/homeassistant/lib/python3.6/site-packages/urllib3/connectionpool.py", line 346, in _make_request
    self._validate_conn(conn)
  File "/srv/homeassistant/lib/python3.6/site-packages/urllib3/connectionpool.py", line 850, in _validate_conn
    conn.connect()
  File "/srv/homeassistant/lib/python3.6/site-packages/urllib3/connection.py", line 346, in connect
    _match_hostname(cert, self.assert_hostname or hostname)
  File "/srv/homeassistant/lib/python3.6/site-packages/urllib3/connection.py", line 356, in _match_hostname
    match_hostname(cert, asserted_hostname)
  File "/usr/lib/python3.6/ssl.py", line 327, in match_hostname
    % (hostname, ', '.join(map(repr, dnsnames))))
ssl.CertificateError: hostname 'my.plexapp.com' doesn't match either of 'plex.tv', 'www.plex.tv'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.6/site-packages/requests/adapters.py", line 440, in send
    timeout=timeout
  File "/srv/homeassistant/lib/python3.6/site-packages/urllib3/connectionpool.py", line 639, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/srv/homeassistant/lib/python3.6/site-packages/urllib3/util/retry.py", line 388, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='my.plexapp.com', port=443): Max retries exceeded with url: /users/sign_in.xml (Caused by SSLError(CertificateError("hostname 'my.plexapp.com' doesn't match either of 'plex.tv', 'www.plex.tv'",),))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity_component.py", line 171, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=self.hass.loop)
  File "/usr/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
    return fut.result()
  File "/usr/lib/python3.6/asyncio/futures.py", line 245, in result
    raise self._exception
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/homeassistant/.homeassistant/custom_components/sensor/plex.py", line 63, in setup_platform
    plex_token)], True)
  File "/home/homeassistant/.homeassistant/custom_components/sensor/plex.py", line 86, in __init__
    user = MyPlexAccount(plex_user, plex_password)
  File "/srv/homeassistant/lib/python3.6/site-packages/plexapi/myplex.py", line 79, in __init__
    data, initpath = self._signin(username, password, timeout)
  File "/srv/homeassistant/lib/python3.6/site-packages/plexapi/myplex.py", line 87, in _signin
    data = self.query(self.SIGNIN, method=self._session.post, auth=(username, password), timeout=timeout)
  File "/srv/homeassistant/lib/python3.6/site-packages/plexapi/myplex.py", line 152, in query
    response = method(url, headers=headers, timeout=timeout, **kwargs)
  File "/srv/homeassistant/lib/python3.6/site-packages/requests/sessions.py", line 555, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/srv/homeassistant/lib/python3.6/site-packages/requests/sessions.py", line 508, in request
    resp = self.send(prep, **send_kwargs)
  File "/srv/homeassistant/lib/python3.6/site-packages/requests/sessions.py", line 618, in send
    r = adapter.send(request, **kwargs)
  File "/srv/homeassistant/lib/python3.6/site-packages/requests/adapters.py", line 506, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='my.plexapp.com', port=443): Max retries exceeded with url: /users/sign_in.xml (Caused by SSLError(CertificateError("hostname 'my.plexapp.com' doesn't match either of 'plex.tv', 'www.plex.tv'",),))

Expected: Plex sensor should work :)

Config:

  - platform: plex
    name: PlexSpy
    host: 192.168.2.212
    port: 32400
    username: !secret plex_user
    password: !secret plex_password
@ryanm101
Copy link
Contributor

This is an upstream issue

https://github.com/pkkid/python-plexapi/blob/master/plexapi/myplex.py

line 70: SIGNIN = 'https://my.plexapp.com/users/sign_in.xml' # get with auth

@ryanm101
Copy link
Contributor

workaround is to use token to authenticate until it is fixed by the good folks over at plexapi:
https://github.com/pkkid/python-plexapi/

@arsaboo
Copy link
Contributor Author

arsaboo commented Jan 11, 2018

Filed a ticket on the plexapi lib pkkid/python-plexapi#246

@ryanm101
Copy link
Contributor

ryanm101 commented Jan 11, 2018

Another "better" fix (until 3.0.6 is released) for the braver is find and edit the file plexapi/myplex.py

Replace SIGNIN = 'https://my.plexapp.com/users/sign_in.xml' # get with auth
with SIGNIN = 'https://plex.tv/users/sign_in.xml' # get with auth

@arsaboo arsaboo changed the title Plex sensor not working Plex sensor not working when using username/password Jan 11, 2018
@ryanm101 ryanm101 mentioned this issue Mar 9, 2018
2 tasks
@home-assistant home-assistant locked and limited conversation to collaborators Jul 26, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants