fix(tls): Enable IPv6 support in ssl_client connect #9470
Merged
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
Update ssl_client.cpp to support IPv6 addresses. The change is similar to the code in NetworkClient.cpp, checking the family of the passed in address and configure the socket and socket address accordingly, for either IPv6 or IPv4 as specified in the address.
Tests scenarios
Tested with M5Stack Core 2, using the following PlatformIO configuration and the test app from https://github.com/sgryphon/iot-demo-build/tree/main/m5stack/m5unified_wifi_https
Results work for TLS across all network types and destinations:
Example IPv6-only network TLS (HTTPS) connection to IPv4-only server, via NAT64. Device sees the DNS64 address (DNS result), destination server (in the response) sees the IPv4 NAT address.
Alternatively, if the LWIP fix is not available, you can combine this fix and the IPv6 DNS workaround. This also works across all network types and destinations.
Related links
This is the last part of the issues in #9143; once all of the changes are merged, then IPv6 will work across HTTP and TLS/HTTPS, using the default configuration, for all network types and destination types.
Also see the IPv6 discussion, #9009
First example:
Second example (without LWIP fix):