How do I set the TLS/SNI (https://en.wikipedia.org/wiki/Server_Name_Indication) in the Python/C++ gRPC client API?
In other words, what's the equivalent of setting the -servername
in openssl s_client
?
I have verified my TLS server works by using the correct flags on openssl s_client
:
openssl s_client -connect "myserver.tunnel.dev:4443" -servername "myserver.tunnel.dev"
However, I wasn't able to setup the credentials correct with the Python /C++ API:
uri = "myserver.tunnel.dev:4443"
hostname = "myserver.tunnel.dev"
creds = grpc.ssl_channel_credentials(
root_certificates=dev_cert)
# root_certificates=certificate_chain)
# certificate_chain=certificate_chain)
channel = grpc.secure_channel(uri, creds,
options=(('grpc.ssl_target_name_override', hostname),)
)
This throws:
grpc._channel._Rendezvous: <_Rendezvous of RPC that terminated with (StatusCode.UNAVAILABLE, Connect Failed)>
In the ChannelOptions
struct, the closest option I could find is ssl_target_name_override
, which doesn't work either.