-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implements SSL connection #20
Conversation
Smankusors, |
Yeah that is something I'm worried about, especially the certificate verification :/ |
Smankusors , But ssl feature very important and I suggest:
Note! SOCK_SSL_TIMEOUT: We need this to handle all timeout related events, but ssl needs more time for connect so instead of default 0.05 we should use other value 1sec or 0.5 sec If you are ok with this plan - lets modify existing pull request. For new folder I will create README by myself - so don't worry here. And again thx a lot for all your investigations as I said ssl important feature and all your findings are very and very helpful. |
Hmm what is this new folder For |
Main lib designed for cPython and micropython support thus I can't place code there. Within SSL dir will be cPython with SSL feature. You can create base and then I will remove not needed micropython staff
You see unfortunately most of users do not use branches. Even code sometimes just copied from web pages )) If we will have correct REAMDE in ssl folder and annotations in main README thinks for end users will be more simple and clear.
Here is no actions for micropython. As i said in prev comment we are blocked with wrap_socket call limitations. So focus should be pointed just to cpython ssl implementation
This is true. But library can be used for custom local servers and put hardcoded certificate names probably not correct way if we want flexibility of code usage. Here you see we are balancing between usability and flexibility. |
Hmm so the main program code will be something like this?
Oh yeah I forgot to say that the |
Yeap, definitely right. You can place it as keyword parameter with default None value will cover only case when ssl_cert was defined
Not sure... I was thinking about copy -paste from ssl folder to root. Library name will be the same. |
Ehm... if we create a new folder specially for SSL... why not always wrap the socket?
or.... create a new class that extends the Blynk class? |
Yeap this was in my mind too, but not pronounced )) Sure we need to do this. Port should be changed , socket will be only ssl wrapped , msg_id =0 etc. Micropython library staff i will remove by myself - as I said don't worry here. |
ouh, I really don't have idea about this. Currently I extended the This is my implementation so far :
|
Hi Smankusors, crt file please add to separate "certfificate" folder. Msg id was already corrected by me. So just please add socket wrapper and related staff. Also let's use ssl_cert=None by default if this parameter will be defined by user - only then we will switch to ssl connection mode. About extended classes mentioned by you in prev comment : this is really good solution to software systems. If we have hardware endpoints then we should think about usability, compatibility etc. Thx in advance for your patience. |
wait, how about if the user not self signed the certificate but using Let's encrypt? The public certificate usually already built in on the installed system |
Not understood what do you mean ... Do you have example or suggestion what we need to change? |
on line 220 in this pull request, I call Note that if you're using Let's encrypt, you don't need to supply |
As I see from documentations for python2/3 we can define cafile parameter directly within create_default_context call. And there is no need in load_verify_locations line. Still I don't wont to hardcodes and multiple parameters - so suggestion - lets use ssl_cert=None as default for none ssl mode if this parameter will have path defined we will use crt file if ssl_cert='' or "default" or smth like this lets use system default CA |
Hmm which do you think is better? String "default" or const int |
For me ssl_cert="default" looks more user friendly. |
alright it's done, how about it? |
Hi Smankusors ! For default value I was thinking we were discussing system’s default CA certificates: "ssl.create_default_context( .... cafile, capath, cadata represent optional CA certificates to trust for certificate verification, as in SSLContext.load_verify_locations(). If all three are None, this function can choose to trust the system’s default CA certificates instead." Also according the same documentation( https://docs.python.org/3/library/ssl.html) we can use create_default_context directly with cafile argument . So sslContext.load_verify_locations call will be not necessary. And last one comment related to README file - we now use ssl_cert parameter - not ssl. |
1 similar comment
Hi Smankusors ! For default value I was thinking we were discussing system’s default CA certificates: "ssl.create_default_context( .... cafile, capath, cadata represent optional CA certificates to trust for certificate verification, as in SSLContext.load_verify_locations(). If all three are None, this function can choose to trust the system’s default CA certificates instead." Also according the same documentation( https://docs.python.org/3/library/ssl.html) we can use create_default_context directly with cafile argument . So sslContext.load_verify_locations call will be not necessary. And last one comment related to README file - we now use ssl_cert parameter - not ssl. |
sslContext = ssl.create_default_context() | ||
sslContext.verify_mode = ssl.CERT_REQUIRED | ||
if (self.ssl_cert == "default"): | ||
caFile = os.path.dirname(__file__) + "/certificate/_blynk-cloudcom.crt" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use "default" not as hardcode for blynk cloud certificate but as system’s default CA certificates
It means calling ssl.create_default_context(caFile=None)
According this document https://docs.python.org/3/library/ssl.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't do.
The user don't have the blynk cloud certificate in the first place. They must dig this certificate deep on the blynk-lib for C (ESP8266). Without this, the user can't connect to the blynk-cloud.com unless they have this file.
alright, thanks for the merge 😄 |
There's some small example I included on
README.md
file.Also the certificate verification works with blynk-cloud.com (included
_blynk-cloudcom.crt
from blynk-library) and Let's Encrypt certificates :)