Scenario: I have a client implemented in C# that shoud connect to a server using gRPC using SSL for an encrypted Connection. However, the certificate used by the server may or may not be self-signed.
In the docs, I have only seen that I can set up a channel credential either insecure (no SSL at all) or secure by using custom root certificates (or using the public root CAs which will not validate a self-signed cert), which effectively means I would have to make sure that I install the self-signed server certificate as root. Basically, how do I do that programmatically?
var channelCredentials = new SslCredentials(rootAsPem);
// FIXME: specify that channelCredentials can accept self-signed certificates or fetch certificates?
var channel = new Channel("myservice.example.com", channelCredentials);
var client = new Greeter.GreeterClient(channel);
What I would like to implement is to ask the user like "hey, the server that you configured uses a self-signed certificate, are you OK with that?" and if so, install the certificate as a root certificate in the PEM.
My main Questions now are:
- How do I even get the server certificate? All I currently get is an exception.
- Is it possible to avoid having to install the server certificate as a root certificate?