Hyundai-Kia-Connect / kia_uvo

A Home Assistant HACS integration that supports Kia Connect(Uvo) and Hyundai Bluelink. The integration supports the EU, Canada and the USA.
MIT License
438 stars 88 forks source link

api.telematics.hyundaiusa.com certificate verify failed: self-signed certificate in certificate chain #887

Closed Snuffy2 closed 5 months ago

Snuffy2 commented 5 months ago

Region and Brand of car USA Hyundai Palisade

Version of the integration v2.24.4

Describe the bug Not sure if this is happening for anyone else, but I just restarted HA after updating to 2024.6.1 and now the Hyundai Integration isn't working with the error below. I'm not sure if it has anything to do with 2024.6.1 as the error says the issue is with a self-signed cert on the Hyundai servers.

Debug logs if an error occurred

2024-06-07 18:34:53.824 ERROR (MainThread) [custom_components.kia_uvo.config_flow] Unexpected exception
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 715, in urlopen
    httplib_response = self._make_request(
                       ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 404, in _make_request
    self._validate_conn(conn)
  File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 1058, in _validate_conn
    conn.connect()
  File "/usr/local/lib/python3.12/site-packages/urllib3/connection.py", line 419, in connect
    self.sock = ssl_wrap_socket(
                ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/urllib3/util/ssl_.py", line 449, in ssl_wrap_socket
    ssl_sock = _ssl_wrap_socket_impl(
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/urllib3/util/ssl_.py", line 493, in _ssl_wrap_socket_impl
    return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/ssl.py", line 455, in wrap_socket
    return self.sslsocket_class._create(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/ssl.py", line 1042, in _create
    self.do_handshake()
  File "/usr/local/lib/python3.12/ssl.py", line 1320, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain (_ssl.c:1000)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/requests/adapters.py", line 667, in send
    resp = conn.urlopen(
           ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 799, in urlopen
    retries = retries.increment(
              ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/urllib3/util/retry.py", line 592, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.telematics.hyundaiusa.com', port=443): Max retries exceeded with url: /v2/ac/oauth/token (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain (_ssl.c:1000)')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/config/custom_components/kia_uvo/config_flow.py", line 159, in async_step_user
    await validate_input(self.hass, user_input)
  File "/config/custom_components/kia_uvo/config_flow.py", line 63, in validate_input
    token: Token = await hass.async_add_executor_job(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/hyundai_kia_connect_api/HyundaiBlueLinkAPIUSA.py", line 122, in login
    response = self.sessions.post(url, json=data, headers=self.API_HEADERS)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/requests/sessions.py", line 637, in post
    return self.request("POST", url, data=data, json=json, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/requests/adapters.py", line 698, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='api.telematics.hyundaiusa.com', port=443): Max retries exceeded with url: /v2/ac/oauth/token (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain (_ssl.c:1000)')))
cdnninja commented 5 months ago

This looks like either a host issue or a security issue locally.

carrel-gr commented 5 months ago

I'm getting the same error, starting today.

obhatti87 commented 5 months ago

Getting the same error after 2024.6.1 update also. I also did see that when I logged into Hyundai, I was asked to provide a code sent to my cell like 2FA. I don't remember that before. Also had to verify my email after login into Hyundai.

ptrtech1 commented 5 months ago

image Same error

estiens commented 5 months ago

Same here starting today. I know the app recently had an update so maybe the api did don't think home assistant related as I had it before and after update but not sure.

If I get a chance I'll try to intercept some calls

SeanPM5 commented 5 months ago

Same here as of a few hours ago. Hyundai USA.

When I launched Hyundai app to check if was an outage on their end, it asked me to login again with a one-time code (sms or email), accept the tos/privacy policy etc. After that the app is working again, but integration is still not connecting.

nprez83 commented 5 months ago

Getting the same issue but with the Kia API. It started last night, also around the time I upgraded to 6.1. I tried deleting and readding the integration and I get this error.

This error originated from a custom integration.

Logger: custom_components.kia_uvo.config_flow
Source: custom_components/kia_uvo/config_flow.py:159
integration: Hyundai / Kia Connect (documentation, issues)
First occurred: 07:36:51 (1 occurrences)
Last logged: 07:36:51

Unexpected exception
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 715, in urlopen
    httplib_response = self._make_request(
                       ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 404, in _make_request
    self._validate_conn(conn)
  File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 1058, in _validate_conn
    conn.connect()
  File "/usr/local/lib/python3.12/site-packages/urllib3/connection.py", line 419, in connect
    self.sock = ssl_wrap_socket(
                ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/urllib3/util/ssl_.py", line 449, in ssl_wrap_socket
    ssl_sock = _ssl_wrap_socket_impl(
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/urllib3/util/ssl_.py", line 493, in _ssl_wrap_socket_impl
    return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/ssl.py", line 455, in wrap_socket
    return self.sslsocket_class._create(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/ssl.py", line 1042, in _create
    self.do_handshake()
  File "/usr/local/lib/python3.12/ssl.py", line 1320, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1000)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/requests/adapters.py", line 667, in send
    resp = conn.urlopen(
           ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 799, in urlopen
    retries = retries.increment(
              ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/urllib3/util/retry.py", line 592, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.owners.kia.com', port=443): Max retries exceeded with url: /apigw/v1/prof/authUser (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1000)')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/config/custom_components/kia_uvo/config_flow.py", line 159, in async_step_user
    await validate_input(self.hass, user_input)
  File "/config/custom_components/kia_uvo/config_flow.py", line 63, in validate_input
    token: Token = await hass.async_add_executor_job(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/hyundai_kia_connect_api/KiaUvoAPIUSA.py", line 188, in login
    response = self.session.post(url, json=data, headers=headers)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/requests/sessions.py", line 637, in post
    return self.request("POST", url, data=data, json=json, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/requests/adapters.py", line 698, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='api.owners.kia.com', port=443): Max retries exceeded with url: /apigw/v1/prof/authUser (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1000)')))
rgnet5 commented 5 months ago

Same here too

bfish2 commented 5 months ago

Same here.

image

nphil commented 5 months ago

Likewise - on Genesis, USA.

cdnninja commented 5 months ago

Could you try update to "master" branch via service call and let me know if fixes it?

Snuffy2 commented 5 months ago

@cdnninja

Setup failed for custom integration 'kia_uvo': Requirements for kia_uvo not found: ['hyundai_kia_connect_api==3.20.4']

It looks like the push of 3.20.4 to PyPi failed: https://github.com/Hyundai-Kia-Connect/hyundai_kia_connect_api/actions/runs/9429277562/job/25975506517

nprez83 commented 5 months ago

FYI @cdnninja, I restored my HAOS back to 2024.6 and the integration now works fine, so whatever the problem is, it's being caused by changes in 2024.6.1

cdnninja commented 5 months ago

@cdnninja


Setup failed for custom integration 'kia_uvo': Requirements for kia_uvo not found: ['hyundai_kia_connect_api==3.20.4']

It looks like the push of 3.20.4 to PyPi failed: https://github.com/Hyundai-Kia-Connect/hyundai_kia_connect_api/actions/runs/9429277562/job/25975506517

Looks like service was down or something. I retried with a dummy commit and it updated.

Please retry updating from master.

Snuffy2 commented 5 months ago

Updated master and it is now using the 3.20.5 api.

Still not working though and seeing this in the logs:

2024-06-08 18:40:12.551 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration kia_uvo which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant

2024-06-08 18:40:45.775 DEBUG (MainThread) [hyundai_kia_connect_api.HyundaiBlueLinkAPIUSA] hyundai_kia_connect_api - initial API headers: {'content-type': 'application/json;charset=UTF-8', 'accept': 'application/json, text/plain, */*', 'accept-encoding': 'gzip, deflate, br', 'accept-language': 'en-US,en;q=0.9', 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36', 'host': 'api.telematics.hyundaiusa.com', 'origin': 'https://api.telematics.hyundaiusa.com', 'referer': 'https://api.telematics.hyundaiusa.com/login', 'from': 'SPA', 'to': 'ISS', 'language': '0', 'offset': '-4', 'sec-fetch-dest': 'empty', 'sec-fetch-mode': 'cors', 'sec-fetch-site': 'same-origin', 'refresh': 'false', 'encryptFlag': 'false', 'brandIndicator': 'H', 'gen': '2', 'client_id': 'm66129Bb-em93-SPAHYN-bZ91-am4540zp19920', 'clientSecret': '<redacted>'}
2024-06-08 18:40:47.712 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 1.937 seconds (success: False)

2024-06-08 18:42:24.097 DEBUG (MainThread) [hyundai_kia_connect_api.HyundaiBlueLinkAPIUSA] hyundai_kia_connect_api - initial API headers: {'content-type': 'application/json;charset=UTF-8', 'accept': 'application/json, text/plain, */*', 'accept-encoding': 'gzip, deflate, br', 'accept-language': 'en-US,en;q=0.9', 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36', 'host': 'api.telematics.hyundaiusa.com', 'origin': 'https://api.telematics.hyundaiusa.com', 'referer': 'https://api.telematics.hyundaiusa.com/login', 'from': 'SPA', 'to': 'ISS', 'language': '0', 'offset': '-4', 'sec-fetch-dest': 'empty', 'sec-fetch-mode': 'cors', 'sec-fetch-site': 'same-origin', 'refresh': 'false', 'encryptFlag': 'false', 'brandIndicator': 'H', 'gen': '2', 'client_id': 'm66129Bb-em93-SPAHYN-bZ91-am4540zp19920', 'clientSecret': '<redacted>'}
2024-06-08 18:42:24.590 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 0.492 seconds (success: False)

2024-06-08 18:42:34.884 DEBUG (MainThread) [hyundai_kia_connect_api.HyundaiBlueLinkAPIUSA] hyundai_kia_connect_api - initial API headers: {'content-type': 'application/json;charset=UTF-8', 'accept': 'application/json, text/plain, */*', 'accept-encoding': 'gzip, deflate, br', 'accept-language': 'en-US,en;q=0.9', 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36', 'host': 'api.telematics.hyundaiusa.com', 'origin': 'https://api.telematics.hyundaiusa.com', 'referer': 'https://api.telematics.hyundaiusa.com/login', 'from': 'SPA', 'to': 'ISS', 'language': '0', 'offset': '-4', 'sec-fetch-dest': 'empty', 'sec-fetch-mode': 'cors', 'sec-fetch-site': 'same-origin', 'refresh': 'false', 'encryptFlag': 'false', 'brandIndicator': 'H', 'gen': '2', 'client_id': 'm66129Bb-em93-SPAHYN-bZ91-am4540zp19920', 'clientSecret': '<redacted>'}
2024-06-08 18:42:35.137 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 0.252 seconds (success: False)

2024-06-08 18:42:55.524 DEBUG (MainThread) [hyundai_kia_connect_api.HyundaiBlueLinkAPIUSA] hyundai_kia_connect_api - initial API headers: {'content-type': 'application/json;charset=UTF-8', 'accept': 'application/json, text/plain, */*', 'accept-encoding': 'gzip, deflate, br', 'accept-language': 'en-US,en;q=0.9', 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36', 'host': 'api.telematics.hyundaiusa.com', 'origin': 'https://api.telematics.hyundaiusa.com', 'referer': 'https://api.telematics.hyundaiusa.com/login', 'from': 'SPA', 'to': 'ISS', 'language': '0', 'offset': '-4', 'sec-fetch-dest': 'empty', 'sec-fetch-mode': 'cors', 'sec-fetch-site': 'same-origin', 'refresh': 'false', 'encryptFlag': 'false', 'brandIndicator': 'H', 'gen': '2', 'client_id': 'm66129Bb-em93-SPAHYN-bZ91-am4540zp19920', 'clientSecret': '<redacted>'}
2024-06-08 18:42:55.730 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 0.206 seconds (success: False)
Screenshot 2024-06-08 at 6 57 12 PM
nprez83 commented 5 months ago

Don't think it's their service @cdnninja. It's something related to 2024.6.1. Integration is working fine right now after I reverted to 2024.6.

SeanPM5 commented 5 months ago

Now that I think about it, it did happen shortly after updating to 2024.6.1 (I just assumed that was a coincidence).

Here is the changelog for 2024.6.1, there are some updates to http libraries and stuff: https://github.com/home-assistant/core/releases/tag/2024.6.1

cdnninja commented 5 months ago

Could you give it another try on master?

SeanPM5 commented 5 months ago

latest master branch works for me, logged in fine and no errors

nprez83 commented 5 months ago

I've just upgraded to 2024.6.1, which again broke the integration, and then upgraded to the latest version of the integration, 2.24.5, which fixed the problem. Thanks as always for the prompt reply and the ongoing great work @cdnninja.

cdnninja commented 5 months ago

Credit goes to @whinis he figured this one out.