Unable to connect to ASP.Net gRPC Server with certificate applied when trying to connect from C# Client
See original GitHub issueI 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:
- Created 2 years ago
- Comments:7 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
TLS 1.2 might be disabled on your computer: https://docs.microsoft.com/en-us/windows-server/security/tls/tls-registry-settings#tls-dtls-and-ssl-protocol-version-settings
Closing because of lack of activity.