Running a gRPC service on Mac
At the time of writing, you cannot apply TLS while running gRPC Server on Mac. This is because of missing Application Layer Protocol Negotiation (ALPN) support on the operating system. So, to make it work, you need to enable HTTP access to the server instead of HTTPS.
Configuring server-side components
First, you need to enable an unencrypted endpoint HTTP/2 endpoint inside your application. To do so, open the Program.cs
file inside your gRPC server project. Then, add the following using
statement on top of it:
using Microsoft.AspNetCore.Server.Kestrel.Core;
Then, inside the Main
method (which is the entry point into the application), add the following block of code inside the call to the ConfigureWebHostingDefaults
method:
webBuilder.ConfigureKestrel(options => { options.ListenLocalhost(<port number>, o => o.Protocols = HttpProtocols.Http2); });
Replace <port number>
with the actual port number of the HTTP endpoint, which can be found under the applicationUrl
key in the launchSettings.json
file, which is located in the Properties
folder of the project.
Once you've done this, your application will be ready to accept insecure HTTP/2 requests on the specified port number.
Modifying the client-side configuration
Because TLS doesn't work on the server, you won't be able to send requests to it via the HTTPS endpoint. So, while creating the GrpcChannel
object in the client application, you will need to pass the HTTP URL into it. The specific URL can be found under the applicationUrl
key in the launchSettings.json
file, which is located in the Properties
folder of the gRPC server project.