JurajNyiri / pytapo

Python library for communication with Tapo Cameras
MIT License
279 stars 58 forks source link

requests.exceptions.SSLError #65

Closed NicoCaldo closed 1 year ago

NicoCaldo commented 1 year ago

I'm having an issue connecting to the camera.

Everything works fine on the app and I can stream the video with VLC and ping the IP. My credentials are correct and I've tried both my mail and admin

from pytapo import Tapo

user = "admin" # user you set in Advanced Settings -> Camera Account
password = "my_passowrd" # password you set in Advanced Settings -> Camera Account
host = "10.10.96.28" # ip of the camera, example: 192.168.1.52

tapo = Tapo(host, user, password)

print(tapo.getBasicInfo())

I'm having requests.exceptions.SSLError: HTTPSConnectionPool(host='10.10.96.28', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLError(1, '[SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:997)')))

I have 2FA ON, could it be the issue?

NicoCaldo commented 1 year ago

Seems to be an issue with Python 3.10 https://stackoverflow.com/questions/71006708/getting-sslv3-alert-handshake-failure-when-trying-to-connect-to-imap

NicoCaldo commented 1 year ago

Downgrading to Python 3.9 fixed the issue. I would fix the issue tho, as Python 3.10 is pretty common now

NicoCaldo commented 1 year ago

A workaround is to pip install requests "urllib3<2" as explained here and then add requests.packages.urllib3.util.ssl_.DEFAULT_CIPHERS += 'AES256-GCM-SHA384' on top of __init__.py

Clearly, this solution needs urllib3 in a version that it's not the latest

JurajNyiri commented 1 year ago

Interestingly, this is not an issue when used within HA.

I am also not getting this with python3.10.

jnyiri@Jurajs-MacBook-Air pytapo % python3.10 --version
Python 3.10.11
jnyiri@Jurajs-MacBook-Air pytapo % python3.10 test2.py 
{'device_info': {'basic_info': {'device_type': 'SMART.IPCAMERA', 'device_model': 'C200', 'device_name': 'C200 1.0', 'device_info': 'C200 1.0 IPC', 'hw_version': '1.0', 'sw_version': '1.1.16 Build 211209 Rel.37726n(4555)', 'device_alias': 'Bedroom', 'features': '3', 'barcode': '', 'mac': '...', 'dev_id': '...', 'oem_id': '...', 'hw_desc': '...'}}}

Edit: I was able to replicate this by running:

python3.10 -m pip install --upgrade urllib3
python3.10 -m pip install --upgrade requests
JurajNyiri commented 1 year ago

Fixed in pytapo==3.2.

OrlandoStrike commented 10 months ago

I use Python 3.11, having same issues, i just downgraded the library "urllib3" to 1.26, and now it works just fine.

image

efalk commented 8 months ago

Seeing this with Python 3.12.1. I can probably provide a minimal test case if needed.

mic-user commented 7 months ago

Guys, there is a solution at https://arista.my.site.com/AristaCommunity/s/article/Python-3-10-and-SSLV3-ALERT-HANDSHAKE-FAILURE-error paragraph 'Python 3.10 solution (client side)'. Which is really works.

JurajNyiri commented 7 months ago

This has been fixed since July 2023... Just update.

https://github.com/JurajNyiri/pytapo/issues/65#issuecomment-1656470805