set _use_insecure
back to false
in setCACert
method on WiFiClientSecure.cpp
#8386
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of Change
WiFiClientSecure::setCACert
that will help improve security when using WiFiClientSecure library._use_insecure = false
at the end of the above method. It is neccessary to prevent accidentlly insecure connection of the end user in case they usewifiClientSecure.setInsecure()
then in other endpoint they need to usesetCACert
.Tests scenarios
The following test code (on ESP32 dev kit) will show potential security problem of using the library:
Following is the debuging message output from the above code:
In this usage, we see that:
setCACert
will take no effect in the code. If the user hasn't turn on the debug flag, they will not notice this.After modification the code as mentioned in the description section, the output debug message of the test code is:
Now the library works as expected.
Related links
There is another problem with the library as you can see in the debug message:
[E][WiFiClient.cpp:313] setSocketOption(): fail on 0, errno: 9, "Bad file number"
. I see it was reported at various places. I've try to solve this but it seem to be too complicated for me. I suggest to add a newvoid WiFiClientSecure::begin()
method to address this problem, but it will break the existing code API. So I leave it as discussion (I am sorry).Thank you!