Livius
unread,May 11, 2022, 6:46:10 PMMay 11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message as abuse
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to grpc.io
Hi!
I implemented a simple gRPC client in C# .NET Framework
4.7.2 (WinHttpHandler) and a gRPC server in Python3 (grpcio 1.46.0) for testing.
In C# .NET Framework i can use only client and it is mandantory to using TLS with WinHttpHandler. Following code parts show my solution for it. I could generate well the cert and key for my server, is my code correct to use it for TLS client?
WinHttpHandler handler = new WinHttpHandler()
{
SslProtocols = SslProtocols.Tls,
WindowsProxyUsePolicy = WindowsProxyUsePolicy.DoNotUseProxy
};
X509Certificate2 cert = new X509Certificate2("server.crt");
handler.ClientCertificates.Add(cert);
GrpcChannelOptions options = new GrpcChannelOptions() { HttpHandler = handler };
this.channel = GrpcChannel.ForAddress(this.textBox_url.Text, options);
this.client = new GExchange.GExchangeClient(this.channel);
When i test it with my gRPC Python server and try to call a gRPC method, i got an "A connection with the server could not be established" exception in C# then i also got an "UNSUPPORTED_PROTOCOL" error in Python server log. Can somebody help what is this issue? It seems to me gRPC Python server requires an other cryptographic protocol for example TLS v1.3 maybe, but in C# .NET Framework for WinHttpHandler i can use only TLS v1.0, v1.1, v1.2. Can somebody help how can i change TLS version of my gRPC Python server to any older version? By the way, if i test it in a Python client and Python server everything is working well.
gRPC Python server error:
E0511 17:55:18.799000000 14676 src/core/tsi/ssl_transport_security.cc:1495] Handshake failed with fatal error SSL_ERROR_SSL: error:100000f0:SSL routines:OPENSSL_internal:UNSUPPORTED_PROTOCOL.
D0511 17:55:18.802000000 14676 src/core/lib/security/transport/security_handshaker.cc:181] Security handshake failed: {"created":"@1652284518.802000000","description":"Handshake failed","file":"src/core/lib/security/transport/security_handshaker.cc","file_line":377,"tsi_code":10,"tsi_error":"TSI_PROTOCOL_FAILURE"}
D0511 17:55:18.806000000 14676 src/core/ext/transport/chttp2/server/chttp2_server.cc:427] Handshaking failed: {"created":"@1652284518.802000000","description":"Handshake failed","file":"src/core/lib/security/transport/security_handshaker.cc","file_line":377,"tsi_code":10,"tsi_error":"TSI_PROTOCOL_FAILURE"}
C# .NET Framework exception:
Status(StatusCode="Internal", Detail="Error starting gRPC call. HttpRequestException: An error occurred while sending the request. WinHttpException: Error 12029 calling WINHTTP_CALLBACK_STATUS_REQUEST_ERROR, 'A connection with the server could not be established'.", DebugException="System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.Http.WinHttpException: Error 12029 calling WINHTTP_CALLBACK_STATUS_REQUEST_ERROR, 'A connection with the server could not be established'.
at System.Threading.Tasks.RendezvousAwaitable`1.GetResult()
at System.Net.Http.WinHttpHandler.<StartRequestAsync>d__122.MoveNext()
--- End of inner exception stack trace ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Grpc.Net.Client.Internal.GrpcCall`2.<RunCall>d__73.MoveNext() in /_/src/Grpc.Net.Client/Internal/GrpcCall.cs:line 493")