title: gRPC server .net framework - how to configure to use a TLS certificate
body: <p>I am new to gRPC and just exploring options for communications in my .net framework servers.</p>
  <p>Due to the age and size of the server projects, it may be some time before these can be ported to .net 5+, but I want to allow for newer .net 5+ clients to connect, so want to replace the existing server WCF with something current.</p>
  <p>My WCF always used Windows Authentication for encryption, which I can't wait to get away from due to cross domain issues, so would want to use TLS.</p>
  <p>I am finding it hard to find examples on how to do this, especially in .net framework, as most examples are .net core.</p>
  <p>Here is some typical(ish) example code:</p>
  <pre><code>     static async Task Main()
          {
              const int port = 10042;
              
              var server = new Grpc.Core.Server
              {
                  Ports = { new ServerPort(&quot;localhost&quot;, 10042, ServerCredentials.Insecure) }
              };
              server.Services.AddCodeFirst&lt;ICalculator&gt;(new Calculator());
              server.Services.AddCodeFirst&lt;ITimeService&gt;(new TimeService());
              server.Start();
  
              Console.WriteLine(&quot;server listening on port &quot; + port);
              Console.ReadKey();
  
              await server.ShutdownAsync();
       }
  </code></pre>
  <p>Ignore the <code>AddCodeFirst</code> these are some other experiments, however every example seems to use <code>ServerCredentials.Insecure</code>, and they all say to NOT use this in production (which I would not want to), but frustratingly they then do not show how to use a TLS certificate. How can I do this?</p>
  <p>Also, for .net framework <strong>clients</strong>, typical code is</p>
  <pre><code>Channel channel = new Channel(&quot;localhost&quot;, 10042, ChannelCredentials.Insecure);
  </code></pre>
  <p>The only option seems to be <code>Insecure</code></p>
  <p>Finally also, for the server, it is possible to use a self signed certificate?</p>