Skip to content

Instantly share code, notes, and snippets.

@anlsh
Created March 3, 2021 20:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anlsh/a15adf2244a5e3fba74c4df0520e1f40 to your computer and use it in GitHub Desktop.
Save anlsh/a15adf2244a5e3fba74c4df0520e1f40 to your computer and use it in GitHub Desktop.
toy-dotnetcore-client.cs
class Program
{
public static X509Certificate2 GetCert() {
// Get the same cer the server is using... this function definitely works
}
static async Task Main(string[] args)
{
var handler = new HttpClientHandler();
handler.ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;
var httpClient = new HttpClient(handler);
var channel = GrpcChannel.ForAddress("https://localhost:50052/", new GrpcChannelOptions
{
HttpClient = httpClient
});
var client = new Greeter.GreeterClient(channel);
var reply = await client.SayHelloAsync(
new HelloRequest { Name = "GreeterClient" });
Console.WriteLine("Greeting: " + reply.Message);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment