flobz / psa_car_controller

Control psa car with connected_car v4 API.
GNU General Public License v3.0
419 stars 221 forks source link

Invalid or expired client certificate #416

Closed TheRealSlimSchaali closed 1 year ago

TheRealSlimSchaali commented 1 year ago

Describe the bug Below error in log appears every time I try to log in within the config screen.

To Reproduce Steps to reproduce the behavior:

  1. Config in Home Assistant
  2. when the bug append ?
  3. Does it persist after restarting the program? Yes
  4. Does it persist after recreate config by going to http://server_address:port/config?

Config file I use country code DE.

Environment (please complete the following information):

Traceback (most recent call last): File "/psa_car_controller/libs/psa/setup/app_decoder.py", line 76, in firstLaunchConfig res_dict = res2.json()["success"] KeyError: 'success' {"code":"495", "message": "Invalid or expired client certificate"}

Additional context Add any other context about the problem here.

TheRealSlimSchaali commented 1 year ago

Thanks in advance for any help. In case you need more info, please let me know.

johanwillemsen1991 commented 1 year ago

I have the same issue. Environment (please complete the following information):

OS: Home Assistant on Odroid C4 Peugeot e2008 Application version 2.6.0

I tried to replicate it in a standalone docker of PSACC, get the same message.

File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psa/setup/app_decoder.py", line 78, in firstLaunchConfig

res_dict = res2.json()["success"]

KeyError: 'success'

{"code":"495", "message": "Invalid or expired client certificate"}

2022-10-29 08:08:00,373 :: ERROR :: Traceback (most recent call last):

File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psa/setup/app_decoder.py", line 78, in firstLaunchConfig

res_dict = res2.json()["success"]

KeyError: 'success'

{"code":"495", "message": "Invalid or expired client certificate"}

Traceback (most recent call last):

File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psa/setup/app_decoder.py", line 78, in firstLaunchConfig

res_dict = res2.json()["success"]

KeyError: 'success'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):

File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/web/view/config_views.py", line 133, in connectPSA

res = firstLaunchConfig(app_name, email, password, countrycode)

File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psa/setup/app_decoder.py", line 87, in firstLaunchConfig

raise Exception(msg) from ex

Exception: Traceback (most recent call last): ` File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psa/setup/app_decoder.py", line 78, in firstLaunchConfig

res_dict = res2.json()["success"]

KeyError: 'success'

{"code":"495", "message": "Invalid or expired client certificate"}

sebastioune commented 1 year ago

HA OS 9.3 HA version 2022.10.5 Psa controller Current version: v2.6.0

first time installation, country code FR => same message unable to receive SMS code also

172.30.32.1 - - [29/Oct/2022 21:24:25] "POST /_dash-update-component HTTP/1.1" 200 - Requested API level 30 is larger than maximum we have, returning API level 28 instead. 172.30.32.1 - - [29/Oct/2022 21:24:49] "POST /_dash-update-component HTTP/1.1" 200 - Requested API level 30 is larger than maximum we have, returning API level 28 instead. 2022-10-29 21:25:10,339 :: ERROR :: Traceback (most recent call last): File "/psa_car_controller/libs/psa/setup/app_decoder.py", line 76, in firstLaunchConfig res_dict = res2.json()["success"] KeyError: 'success' {"code":"495", "message": "Invalid or expired client certificate"} 172.30.32.1 - - [29/Oct/2022 21:25:10] "POST /_dash-update-component HTTP/1.1" 200 - 172.30.32.1 - - [29/Oct/2022 21:26:22] "GET / HTTP/1.1" 200 -

Any ideas ?

michthom commented 1 year ago

I'm also seeing the same error, don't know if it's related to my signing up using the My Peugeot app just minutes before (successfully) with the same credentials?

kurim commented 1 year ago

After decode the certifcate you can see it is not renewed by PSA.

Common Name: MZPMYMA1 Issued By: PSA Peugeot Citroen Issuing Certificate: PSA Peugeot Citroen Programs Partners Serial Number: 68CB4F87B935FA565A550A1E Signature: sha256WithRSAEncryption Valid From: 14:22:13 28 Oct 2021 Valid To: 14:22:13 28 Oct 2022

So to get it work we need an updated cert.

Temporary workaround: vi /usr/local/lib/python3.9/dist-packages/psa_car_controller/psa/setup/app_decoder.py

Line 17 GITHUB_USER change from: flobz to kurim

I have modify his apk with the new crt, this should do it for now, as long as flobz not update his apk repo

TheRealSlimSchaali commented 1 year ago

After decode the certifcate you can see it is not renewed by PSA.

Common Name: MZPMYMA1 Issued By: PSA Peugeot Citroen Issuing Certificate: PSA Peugeot Citroen Programs Partners Serial Number: 68CB4F87B935FA565A550A1E Signature: sha256WithRSAEncryption Valid From: 14:22:13 28 Oct 2021 Valid To: 14:22:13 28 Oct 2022

So to get it work we need an updated cert.

Temporary workaround: vi /usr/local/lib/python3.9/dist-packages/psa_car_controller/psa/setup/app_decoder.py

Line 17 GITHUB_USER change from: flobz to kurim

I have modify his apk with the new crt, this should do it for now, as long as flobz not update his apk repo

Thanks for looking into this issue. Excuse the question, how do I do that patch on the HomeAssistant Add-on. I ssh'ed onto the machine but that file is not there...

kurim commented 1 year ago

Yes this is in issue... I have done it on my desktop in WSL2 Ubuntu, and download the otp.bin to homeassistant. you can open console in portainer to the container change to ./data and download the otp.bin

flobz commented 1 year ago

Hello @kurim , Thanks for the fix ! Can you create a PR ?

kurim commented 1 year ago

Hi @flobz , you can get my modified APK here: psa_apk and put them to your psa_apk.

Then there is need to modify the code. Btw. the App has been Updated to 1.37.0 may be you need to take a look at it, if i use this version I can pass this part but it failed later (need to take a look later this day)

SinaDD commented 1 year ago

After decode the certifcate you can see it is not renewed by PSA.

Common Name: MZPMYMA1 Issued By: PSA Peugeot Citroen Issuing Certificate: PSA Peugeot Citroen Programs Partners Serial Number: 68CB4F87B935FA565A550A1E Signature: sha256WithRSAEncryption Valid From: 14:22:13 28 Oct 2021 Valid To: 14:22:13 28 Oct 2022

So to get it work we need an updated cert.

Temporary workaround: vi /usr/local/lib/python3.9/dist-packages/psa_car_controller/psa/setup/app_decoder.py

Line 17 GITHUB_USER change from: flobz to kurim

I have modify his apk with the new crt, this should do it for now, as long as flobz not update his apk repo

Thankyou very much kurim, with the change works fine.

sebastioune commented 1 year ago

Hi @flobz

after your modification, I delete PSA controller version to reinstall it (in HA OS) but when I config variable I have got this message :'NoneType' object is not subscriptable and nothin in Log tab :

2022-11-01 15:46:34,537 :: WARNING :: Can't get language
2022-11-01 15:46:35,423 :: INFO :: update_data

I am unable also to locate app_decode.py in HA vm

flobz commented 1 year ago

Hi, You need the last version. The release workflow is in progress.

TheRealSlimSchaali commented 1 year ago

@flobz , thanks for all the work. Do you know when the Home Assistant release will be ready?

kurim commented 1 year ago

You can use the beta, but it has the limitation that you can't use ingress for access.

sebastioune commented 1 year ago

it is working in the beta branch for HA 2022.10.5. widget in lovelace have value :-)

many thanks @kurim and @flobz !!