question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to connect to ASP.Net gRPC Server with certificate applied when trying to connect from C# Client

See original GitHub issue

I created a server certificate (localhost.pfx) in Windows 10 and hosted the gRPC server in Kestrel using the se same certificate. This is how I configured the server. The service started and listening on: https://0.0.0.0:50051.

 webBuilder.ConfigureKestrel((context, serverOptions) =>
                    {
                        serverOptions.Listen(IPAddress.Any, 50051, listenOptions =>
                        {
                            listenOptions.Protocols = HttpProtocols.Http2;
                            listenOptions.UseHttps("localhost.pfx", "12345678");
                        });
                    }).UseStartup<Startup>();

Now I tried connecting to the gRPC service using a C# Client (same machine),

var httpHandler = new HttpClientHandler();
            httpHandler.ServerCertificateCustomValidationCallback =
                HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;
            var channel = GrpcChannel.ForAddress("https://localhost:50051",
                new GrpcChannelOptions { HttpHandler = httpHandler });
            dataClient = new Data.DataClient(channel);

I am getting below error,

Grpc.Core.RpcException: Status(StatusCode="Internal", Detail="Error starting gRPC call. HttpRequestException: HTTP/2 requires TLS 1.2 or newer, but 'Tls11' was negotiated.", DebugException="System.Net.Http.HttpRequestException: HTTP/2 requires TLS 1.2 or newer, but 'Tls11' was negotiated.
   at System.Net.Http.HttpConnectionPool.GetHttp2ConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
   at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at Grpc.Net.Client.Internal.GrpcCall`2.RunCall(HttpRequestMessage request, Nullable`1 timeout)")
   at Grpc.Net.Client.Internal.HttpClientCallInvoker.BlockingUnaryCall[TRequest,TResponse](Method`2 method, String host, CallOptions options, TRequest request)
   at Grpc.Core.Interceptors.InterceptingCallInvoker.<BlockingUnaryCall>b__3_0[TRequest,TResponse](TRequest req, ClientInterceptorContext`2 ctx)
   at Grpc.Core.ClientBase.ClientBaseConfiguration.ClientBaseConfigurationInterceptor.BlockingUnaryCall[TRequest,TResponse](TRequest request, ClientInterceptorContext`2 context, BlockingUnaryCallContinuation`2 continuation)
   at Grpc.Core.Interceptors.InterceptingCallInvoker.BlockingUnaryCall[TRequest,TResponse](Method`2 method, String host, CallOptions options, TRequest request)

How can I make sure client is using TLS 1.2 or how do I specify the root certificates in SslCredentialsOptions?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

0reactions
JamesNKcommented, Aug 4, 2021

Closing because of lack of activity.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshoot gRPC on .NET
The ASP.NET Core gRPC template and samples use TLS by default. You'll see the following error message when you attempt to start the...
Read more >
Grpc .Net client fails to connect to server with SSL
I made a working client on the .NET Framework c with a server on .NET Core on localhost: static async Task Main(string[] args)...
Read more >
How can I solve this unhandled exception "Error starting ...
On Ubuntu 18.04, I am trying the template project for gRPC in ASP.NET ... starting gRPC call: The SSL connection could not be...
Read more >
[Solved]-Grpc .Net client fails to connect to server with SSL-C#
I got it working with SSL port by using the Server's certificate in pem format in the client. SslCredentials secureCredentials = new SslCredentials(File....
Read more >
Grpc internal error. I am using WinHttpHandler as was mentio
Grpc internal error. I am using WinHttpHandler as was mentioned in this official example. * is in grpc-stub. Connect and share knowledge within...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found