How can I turn off HTTPS on gRPC server? Is there any option?
Asked
Active
Viewed 2,460 times
7
-
Are you talking about gRPC within ASP.NET Core 3.0? While it is not technically required by HTTP2 (which gRPC uses), all browsers decided to force it anyway -- so disabling it may not be useful. – Cory Nelson Aug 22 '19 at 06:18
-
Did you find the way to disable https? – Edik Mkoyan Apr 29 '21 at 07:25
1 Answers
1
Despite it's an old question, I had to do this by myself recently and here is how I did it, based on the ASP.NET Core template from Visual Studio:
First you'll have to configure the kestrel webserver to use the HTTP2 protocol for HTTP (usually in Program.cs):
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.ConfigureKestrel(options =>
options.ConfigureEndpointDefaults(defaults =>
defaults.Protocols = HttpProtocols.Http2));
webBuilder.UseStartup<Startup>();
});
Now the server should be able to handle all calls, regardless of using HTTP or HTTPS.
After you did that, you just have to tell the client to allow using HTTP2 without HTTPS before you make your first call to the gRPC server:
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
var client = new GrpcTest.GrpcTestClient(GrpcChannel.ForAddress("http://localhost:5000"));
Sources: