title: SSL Certification for GRPC
body: <p>Can you help me with ssl certification for gRPC server?</p>
  
  <p>This is how i'm doing it with <strong>C# Core Console application</strong>:</p>
  
  <pre><code>const int Port = 50051;
  const string host = "127.0.0.1";
  
  var cacert = File.ReadAllText(@"Certs/ca.crt");
  var servercert = File.ReadAllText(@"Certs/server.crt");
  var serverkey = File.ReadAllText(@"Certs/server.key");
  var keypair = new KeyCertificatePair(servercert, serverkey);
  var sslCredentials = new SslServerCredentials(new List&lt;KeyCertificatePair&gt;() { keypair }, cacert, false);
  
  
  var server = new Server()
  {
      // setup host, port and server credentials
      Ports = { new ServerPort(host, Port, sslCredentials) },
      // register the service we built earlier
      Services = { Messages.BindService(new MessagesImpl()) }
  };
  
  server.Start();
  </code></pre>
  
  <p>I don't know how to provide SslServerCredentials in <strong>ASP.NET core gRPC Server</strong>? </p>
  
  <p>cRPG server is started by adding in Stattup.cs file in section Configure:</p>
  
  <pre><code>public void ConfigureServices(IServiceCollection services)
  {
      services.AddGrpc();
  }
  
  // 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.UseEndpoints(endpoints =&gt;
      {
          // 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
          endpoints.MapGrpcService&lt;ServiceBaaseClass&gt;();
      });
  }
  </code></pre>