Skip to content
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

WiFiClientSecure owns context, fix stopAllExcept #8136

Merged
merged 4 commits into from
Jun 20, 2021

Conversation

earlephilhower
Copy link
Collaborator

Fixes #8079

Because WiFiClientSecure inherits WiFiClient, and WiFiClientSecureCtx also
inherits WiFiClient, they both end up in the list of TCP connections that
are used for WiFiClient::stopAllExcept(). This would cause the underlying
SSL connection to be closed whenever you attempted to
stopAllExcept(WiFiClientSecure)

Fix by adding a "_owner" pointer in the WiFiClient object which points to
nullptr (default case) or to the associated upper-layer connection.
When stopping all connections except one, only look at the uppermost
connections.

Fixes esp8266#8079

Because WiFiClientSecure inherits WiFiClient, and WiFiClientSecureCtx also
inherits WiFiClient, they both end up in the list of TCP connections that
are used for WiFiClient::stopAllExcept().  This would cause the underlying
SSL connection to be closed whenever you attempted to
stopAllExcept(WiFiClientSecure)

Fix by adding a "_owner" pointer in the WiFiClient object which points to
nullptr (default case) or to the associated upper-layer connection.
When stopping all connections except one, only look at the uppermost
connections.
@earlephilhower
Copy link
Collaborator Author

@d-a-v, I think I need to reverse the sense here and look at the lowest-level, not uppermost one. So hold off on any review or merge, please.

Because there may be multiple copies of the WiFiClientSecure, but only
a single WiFiClientCtx, use the Ctx to check for relatedness on connections.
This will avoid closing SSL connections that were assignment copies.
@earlephilhower
Copy link
Collaborator Author

Okay, good to go @d-a-v. Logic reversed and tested locally.

@d-a-v d-a-v added the alpha included in alpha release label Jun 17, 2021
@earlephilhower earlephilhower merged commit 45e7976 into esp8266:master Jun 20, 2021
@earlephilhower earlephilhower deleted the ctx1 branch June 20, 2021 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
alpha included in alpha release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ESP8266HTTPClient] Updates from HTTPS servers fail before transferring new binary begins
2 participants