Created
March 3, 2021 20:39
-
-
Save anlsh/a15adf2244a5e3fba74c4df0520e1f40 to your computer and use it in GitHub Desktop.
toy-dotnetcore-client.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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