grpc-java icon indicating copy to clipboard operation
grpc-java copied to clipboard

gRPC-okhttp ipv6 link local scope

Open jader-eero opened this issue 3 years ago • 7 comments

What version of gRPC-Java are you using?

1.45.0

What is your environment?

MacOS jdk 8

What did you expect to see?

I expect gRPC-okhttp be able to work with ipv6 link local with scope

What did you see instead?

AndroidNegotiator inside OkHttpProtocolNegotiator.java class is using SNI_HOST_NAME.newInstance(hostname) which throws exception because SNIHostName(String hostname) doesn't accept "%" and we need that for scoping ipv6 link local.

Suggestion would be using SNIHostName(byte[] encoded). To do so we would need to replace line 252 to SNI_HOST_NAME.newInstance(hostname.getBytes())

Steps to reproduce the bug

Any connection that uses configureTlsExtensions from AndroidNegotiator class which uses ipv6 link local with scoping like "%wlan0"

jader-eero avatar Jun 29 '22 19:06 jader-eero

The constructor was looked up (using reflection) as Class.forName("javax.net.ssl.SNIHostName").getConstructor(String.class) on line 197. That will need to be changed to look up a constructor with byte[] type before your suggested change can be made.

Could you create a PR after testing your change works?

sanjaypujare avatar Jun 29 '22 19:06 sanjaypujare

@sanjaypujare I checked locally and that was the issue, I was able to connect successfully after making your and mine suggestion. I'll open a PR soon. Thank you.

jader-eero avatar Jun 30 '22 13:06 jader-eero

PR open https://github.com/grpc/grpc-java/pull/9326

jader-eero avatar Jun 30 '22 13:06 jader-eero

@sanjaypujare could you help me with the PR checks failing? I'm not familiar with them.

jader-eero avatar Jun 30 '22 13:06 jader-eero

with the PR checks failing

Which checks are failing?

sanjaypujare avatar Jun 30 '22 15:06 sanjaypujare

I was able to solve, thank you. Waiting approval from the reviewer.

jader-eero avatar Jun 30 '22 17:06 jader-eero