title: Problems with certificate authentication for grpc client
body: <p>I've created a demo solution with a gRPC client (console application) and a gRPC server application. (the provided template for it on .NET Core 3)</p>
  <p>I'm trying to test certificate authentication between the two, but for some reason it fails with the following error:</p>
  <p><code>AuthenticationException: The remote certificate is invalid according to the validation procedure.&quot;</code></p>
  <p>My <code>Program.cs</code> for the server</p>
  <pre><code>public static IHostBuilder CreateHostBuilder(string[] args) =&gt;
      Host.CreateDefaultBuilder(args)
          .ConfigureWebHostDefaults(webBuilder =&gt;
          {
              webBuilder.UseStartup&lt;Startup&gt;();
              webBuilder.ConfigureKestrel(o =&gt;
              {
                  o.ConfigureHttpsDefaults(o =&gt;
                  {
                      o.ClientCertificateMode = ClientCertificateMode.RequireCertificate;
                      o.ServerCertificate = &lt;MyCertificateWithPrivateKey&gt;;
              });
          });
  </code></pre>
  <p>In the client application I pass the very same certificate inside an HttpHandler, which is passed to the channel I create i.e</p>
  <pre><code>GrpcChannel.ForAddress(&quot;https://localhost:5001&quot;, new GrpcChannelOptions
              {
                  HttpHandler = handler
              });
  </code></pre>
  <p>My server's startup class:</p>
  <pre><code> public class Startup
      {
          // This method gets called by the runtime. Use this method to add services to the container.
          // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
          public void ConfigureServices(IServiceCollection services)
          {
              services.AddGrpc();
              services.AddAuthentication(CertificateAuthenticationDefaults.AuthenticationScheme)
                  .AddCertificate();
          }
  
          // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
          public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
          {
              if (env.IsDevelopment())
              {
                  app.UseDeveloperExceptionPage();
              }
  
              app.UseRouting();
  
              app.UseAuthentication();
  
              app.UseEndpoints(endpoints =&gt;
              {
                  endpoints.MapGrpcService&lt;GreeterService&gt;();
  
                  endpoints.MapGet(&quot;/&quot;, async context =&gt;
                  {
                      await context.Response.WriteAsync(&quot;Communication with gRPC endpoints must be made through a gRPC client. To learn how to create a client, visit: https://go.microsoft.com/fwlink/?linkid=2086909&quot;);
                  });
              });
          }
      }
  </code></pre>
  <p>Appreciate any help you can give me.</p>