blynkkk / lib-python

Blynk IoT library for Python and Micropython
MIT License
237 stars 83 forks source link

SSL Support and msg id issue #19

Closed Smankusors closed 5 years ago

Smankusors commented 5 years ago

So there's issue when I want to implement the SSL support. The id for message that sent to the server starts with 2, not 1. The blynk-server expects hardware sent with id starting from 1, but the library starts from 2 instead. (Code : blynklib.py#L70-L79)

First, server checks that if it's HTTP protocol, then checks if it's from hardware, and then fallback to app pipeline. This works with HTTP (port 80 and 8080) because even it's fallback to the app pipeline, the server never expects it, so it get redirected to hardware pipeline. On the HTTPS (port 443 and 9443), the server expects this is app, but the library sent the hardware messages, and the server not really understand and completely ignore it. Resulting "Auth stage timeout" in the python library.

So actually I already implemented ssl wrapper on the code, but not actually verified the server certificate. I set _msg_id = 0 and it's fully worked. But then I'm confused... is this really intended that... if _msg_id over 65535, then we will use 1 forever?

Thanks,

antohaUa commented 5 years ago

Hi Smankusors, I have just clarified _msg_id = 0 value with blynk server code owners - seems initially they have intention to track counter overflow with this corner value. But now this logic is not used and really we are not limited with setting msg_id to zero by default. You can modify your code without any doubts.

Also If you have intention to share ssl implementation with other users - please fill free to create new pull request ( better with some example ))) but this is optional)

antohaUa commented 5 years ago

Corrected in cpython version https://github.com/blynkkk/lib-python/blob/master/blynklib_cp.py

antohaUa commented 5 years ago

Can be closed.