I get this exception on the client:
Grpc.Core.RpcException: 'Status(StatusCode="Unavailable", Detail="failed to connect to all addresses", DebugException="Grpc.Core.Internal.CoreErrorDetailException: {"created":"@1606620349.107000000","description":"Failed to pick subchannel","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x86\src\core\ext\filters\client_channel\client_channel.cc","file_line":4166,"referenced_errors":[{"created":"@1606620349.107000000","description":"failed to connect to all addresses","file":"T:\src\github\grpc\workspace_csharp_ext_windows_x86\src\core\ext\filters\client_channel\lb_policy\pick_first\pick_first.cc","file_line":398,"grpc_status":14}]}")'
Client channel:
private Channel GetChannel()
{
return new Channel(
_settings.FileServiceUri
, CertificatePEM == null ? ChannelCredentials.Insecure :
new SslCredentials(
CertificatePEM
, new KeyCertificatePair(CertificatePEM, File.ReadAllText("Syrilium.FileUpdater.cer.key"))
)
, new[] {
new ChannelOption(ChannelOptions.MaxReceiveMessageLength,int.MaxValue),
new ChannelOption(ChannelOptions.MaxSendMessageLength,int.MaxValue),
}
);
}
Server config:
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.ConfigureKestrel(kestrelOptions =>
{
var sslCertificate = LoadSSLCertificate();
kestrelOptions.ListenAnyIP(/*IPAddress.Parse("127.0.0.1"),*/ 5001
, listenOptions =>
{
listenOptions.UseHttps(
sslCertificate,
httpsOptions =>
{
//httpsOptions.SslProtocols = SslProtocols.Tls12;
httpsOptions.ClientCertificateMode = ClientCertificateMode.AllowCertificate;
httpsOptions.ClientCertificateValidation = (certificate, chain, errors) =>
{
return true /*certificate.Thumbprint.Equals(_clientThumbprint, StringComparison.OrdinalIgnoreCase)*/;
};
}
);
listenOptions.Protocols = HttpProtocols.Http2;
}
);
});
webBuilder.UseStartup<Startup>();
});
When I just remove
listenOptions.UseHttps...
on the server and use
ChannelCredentials.Insecure
on the client, it works.
How to make those two communicate with HTTPS and my own certificate? Just a simple example of both client and server that work on these newest versions of libraries.
I get a call to
httpsOptions.OnAuthenticate = (ctx, auth) => { };
on service but I don't know what, if anything useful I can do with it? It fails on a handshake.