[GH-ISSUE #334] Problem configuring Spotify: certificate verify failed: unable to get issuer certificate #195

Closed
opened 2026-02-27 23:21:19 +03:00 by kerem · 2 comments
Owner

Originally created by @henrik242 on GitHub (Oct 22, 2018).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/334

When I try to authorize Spotipy (through Home Assistant, which uses spotipy), I authorize with Spotify, but it fails when returning. The log is:

2018-10-22 15:02:36 INFO (MainThread) [homeassistant.components.http.view] Serving /api/spotify to 192.168.86.1 (auth: True)
2018-10-22 15:02:36 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 343, in _make_request
    self._validate_conn(conn)
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 839, in _validate_conn
    conn.connect()
  File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 344, in connect
    ssl_context=context)
  File "/usr/local/lib/python3.7/site-packages/urllib3/util/ssl_.py", line 342, in ssl_wrap_socket
    return context.wrap_socket(sock, server_hostname=server_hostname)
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 412, in wrap_socket
    session=session
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 850, in _create
    self.do_handshake()
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 1108, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get issuer certificate (_ssl.c:1045)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 449, in send
    timeout=timeout
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 638, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/local/lib/python3.7/site-packages/urllib3/util/retry.py", line 398, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='accounts.spotify.com', port=443): Max retries exceeded with url: /api/token (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get issuer certificate (_ssl.c:1045)')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 390, in start
    resp = await self._request_handler(request)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_app.py", line 366, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_middlewares.py", line 106, in impl
    return await handler(request)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/http/static.py", line 66, in staticresource_middleware
    return await handler(request)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/http/real_ip.py", line 34, in real_ip_middleware
    return await handler(request)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/http/ban.py", line 66, in ban_middleware
    return await handler(request)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/http/auth.py", line 68, in auth_middleware
    return await handler(request)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/http/real_ip.py", line 34, in real_ip_middleware
    return await handler(request)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/http/ban.py", line 66, in ban_middleware
    return await handler(request)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/http/auth.py", line 68, in auth_middleware
    return await handler(request)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/http/view.py", line 110, in handle
    result = handler(request, **request.match_info)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/media_player/spotify.py", line 118, in get
    self.oauth.get_access_token(request.query['code'])
  File "/Users/henrik/.homeassistant/deps/lib/python/site-packages/spotipy/oauth2.py", line 216, in get_access_token
    headers=headers, verify=True, proxies=self.proxies)
  File "/usr/local/lib/python3.7/site-packages/requests/api.py", line 116, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/api.py", line 60, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 524, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 637, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 514, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='accounts.spotify.com', port=443): Max retries exceeded with url: /api/token (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get issuer certificate (_ssl.c:1045)')))

I have tried adding the certificate from accounts.spotify.com into a cacerts.pem bundle and starting hass with REQUESTS_CA_BUNDLE=$HOME/.homeassistant/cacerts.pem hass. This doesn't help.

I have also verified that certifi is installed...

I'm running this on macOs 10.4 Mojave. Spotipy 2.4.4 installed with pip3.

Originally created by @henrik242 on GitHub (Oct 22, 2018). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/334 When I try to authorize Spotipy (through Home Assistant, which uses spotipy), I authorize with Spotify, but it fails when returning. The log is: ``` 2018-10-22 15:02:36 INFO (MainThread) [homeassistant.components.http.view] Serving /api/spotify to 192.168.86.1 (auth: True) 2018-10-22 15:02:36 ERROR (MainThread) [aiohttp.server] Error handling request Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 600, in urlopen chunked=chunked) File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 343, in _make_request self._validate_conn(conn) File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 839, in _validate_conn conn.connect() File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 344, in connect ssl_context=context) File "/usr/local/lib/python3.7/site-packages/urllib3/util/ssl_.py", line 342, in ssl_wrap_socket return context.wrap_socket(sock, server_hostname=server_hostname) File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 412, in wrap_socket session=session File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 850, in _create self.do_handshake() File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 1108, in do_handshake self._sslobj.do_handshake() ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get issuer certificate (_ssl.c:1045) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 449, in send timeout=timeout File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 638, in urlopen _stacktrace=sys.exc_info()[2]) File "/usr/local/lib/python3.7/site-packages/urllib3/util/retry.py", line 398, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='accounts.spotify.com', port=443): Max retries exceeded with url: /api/token (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get issuer certificate (_ssl.c:1045)'))) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 390, in start resp = await self._request_handler(request) File "/usr/local/lib/python3.7/site-packages/aiohttp/web_app.py", line 366, in _handle resp = await handler(request) File "/usr/local/lib/python3.7/site-packages/aiohttp/web_middlewares.py", line 106, in impl return await handler(request) File "/usr/local/lib/python3.7/site-packages/homeassistant/components/http/static.py", line 66, in staticresource_middleware return await handler(request) File "/usr/local/lib/python3.7/site-packages/homeassistant/components/http/real_ip.py", line 34, in real_ip_middleware return await handler(request) File "/usr/local/lib/python3.7/site-packages/homeassistant/components/http/ban.py", line 66, in ban_middleware return await handler(request) File "/usr/local/lib/python3.7/site-packages/homeassistant/components/http/auth.py", line 68, in auth_middleware return await handler(request) File "/usr/local/lib/python3.7/site-packages/homeassistant/components/http/real_ip.py", line 34, in real_ip_middleware return await handler(request) File "/usr/local/lib/python3.7/site-packages/homeassistant/components/http/ban.py", line 66, in ban_middleware return await handler(request) File "/usr/local/lib/python3.7/site-packages/homeassistant/components/http/auth.py", line 68, in auth_middleware return await handler(request) File "/usr/local/lib/python3.7/site-packages/homeassistant/components/http/view.py", line 110, in handle result = handler(request, **request.match_info) File "/usr/local/lib/python3.7/site-packages/homeassistant/components/media_player/spotify.py", line 118, in get self.oauth.get_access_token(request.query['code']) File "/Users/henrik/.homeassistant/deps/lib/python/site-packages/spotipy/oauth2.py", line 216, in get_access_token headers=headers, verify=True, proxies=self.proxies) File "/usr/local/lib/python3.7/site-packages/requests/api.py", line 116, in post return request('post', url, data=data, json=json, **kwargs) File "/usr/local/lib/python3.7/site-packages/requests/api.py", line 60, in request return session.request(method=method, url=url, **kwargs) File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 524, in request resp = self.send(prep, **send_kwargs) File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 637, in send r = adapter.send(request, **kwargs) File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 514, in send raise SSLError(e, request=request) requests.exceptions.SSLError: HTTPSConnectionPool(host='accounts.spotify.com', port=443): Max retries exceeded with url: /api/token (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get issuer certificate (_ssl.c:1045)'))) ``` I have tried adding the certificate from accounts.spotify.com into a cacerts.pem bundle and starting hass with `REQUESTS_CA_BUNDLE=$HOME/.homeassistant/cacerts.pem hass`. This doesn't help. I have also verified that certifi is installed... I'm running this on macOs 10.4 Mojave. Spotipy 2.4.4 installed with pip3.
kerem closed this issue 2026-02-27 23:21:19 +03:00
Author
Owner

@ritiek commented on GitHub (Jan 14, 2020):

I'd be curious whether this is still a problem.

There are also many solutions/workarounds posted on here:
https://stackoverflow.com/questions/27835619/urllib-and-ssl-certificate-verify-failed-error

Does it help?

<!-- gh-comment-id:574191564 --> @ritiek commented on GitHub (Jan 14, 2020): I'd be curious whether this is still a problem. There are also many solutions/workarounds posted on here: https://stackoverflow.com/questions/27835619/urllib-and-ssl-certificate-verify-failed-error Does it help?
Author
Owner

@stephanebruckert commented on GitHub (Jan 22, 2020):

Indeed, it looks like this would happen on macos (also suggested here https://github.com/yoavaviram/python-amazon-simple-product-api/issues/129#issuecomment-372084644). Closing as it's not related to the library

<!-- gh-comment-id:576949976 --> @stephanebruckert commented on GitHub (Jan 22, 2020): Indeed, it looks like this would happen on macos (also suggested here https://github.com/yoavaviram/python-amazon-simple-product-api/issues/129#issuecomment-372084644). Closing as it's not related to the library
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotipy#195
No description provided.