Description:
When connecting to a gRPC server via an IPv6 address with TLS enabled, the connection fails on JVM and Android targets.
Root Cause:
kmp-grpc uses OkHttpChannelBuilder internally (Channel.kt), which has a known upstream bug: AndroidNegotiator.configureTlsExtensions() calls
SNIHostName(String) with the hostname, but IPv6 addresses contain : which is not accepted by the SNIHostName String constructor. This causes an
exception during the TLS handshake.
Relevant upstream issues:
Reproduction Steps:
- Start a gRPC server with TLS, listening on an IPv6 address (e.g., [::1]:50051)
- Use Channel.Builder.forAddress("::1", 50051) to create a channel with TLS
- Attempt any gRPC call
- Observe connection failure (typically UNAVAILABLE or an exception from SNIHostName)
Expected Behavior:
IPv6 addresses should work with TLS, the same as IPv4 addresses.
Actual Behavior:
Connection fails when using IPv6 addresses with TLS. IPv4 addresses work fine.
Environment:
- kmp-grpc version: 2.0.0
- Target: JVM / Android
- gRPC-Java: 1.76.0 (bundled with kmp-grpc 2.0.0)
Suggested Fixes (one of):
- Switch from OkHttpChannelBuilder to NettyChannelBuilder on JVM/Android targets (Netty does not have this IPv6 bug)
- Add an option to let users choose the transport implementation
- Upgrade the bundled grpc-okhttp dependency and apply a workaround in AndroidNegotiator
Please let me know if you'd like me to contribute a PR. Happy to help.
Description:
When connecting to a gRPC server via an IPv6 address with TLS enabled, the connection fails on JVM and Android targets.
Root Cause:
kmp-grpc uses OkHttpChannelBuilder internally (Channel.kt), which has a known upstream bug: AndroidNegotiator.configureTlsExtensions() calls
SNIHostName(String) with the hostname, but IPv6 addresses contain : which is not accepted by the SNIHostName String constructor. This causes an
exception during the TLS handshake.
Relevant upstream issues:
Reproduction Steps:
Expected Behavior:
IPv6 addresses should work with TLS, the same as IPv4 addresses.
Actual Behavior:
Connection fails when using IPv6 addresses with TLS. IPv4 addresses work fine.
Environment:
Suggested Fixes (one of):
Please let me know if you'd like me to contribute a PR. Happy to help.