title: Why do I get errors when using gRPC with certs connecting with an IP Address?
body: <p>I'm using .Net (C#) gRPC to build sample Client-Server test applications.
  I'm generating SSL certificates in code using the DiDiSoft library.
  The certificates are generated using the &quot;server&quot; machine name.</p>
  <p>When connect the server and client apps using the machine name, the handshaking works correctly.
  If I use an IP Address, it does not.
  In my reading, it's not recommended to use IPAddresses to generate certs.
  Am I limited to using the machine name when setting up gRPC connections using SSL Certs?</p>
  <p><strong>Sample code for setting up certificates:</strong></p>
  <pre><code>var serverKeypair = rsa.GenerateRsaKeyPair(KeyLength.Length4096);
  serverKeypair.Private.Save(Path.Combine(certsPath, &quot;server.key&quot;));
  X509Name serverCertificateProperties = new X509Name()
  {
      C = &quot;US&quot;,
      ST = &quot;VA&quot;,
      O = &quot;SomeName&quot;,
      OU = &quot;gRPCAPI&quot;,
      CN = &quot;MACHINE-NAME&quot;,
  };
  var serverCert = Certificate.CreateCertificate(serverKeypair.Public, 
                          newca.CACertificate.SubjectPublicKey, 
                          newca.CAPrivateKey, 
                          serverCertificateProperties, 
                          newca.CAProperties, 
                          null, 
                          &quot;01&quot;, 
                          newca.CACertificate.SerialNumber, 
                          true, 
                          new[] { KeyUsages.DigitalSignature }, 
                          DateTime.Now, DateTime.Now.AddYears(1));
  serverCert.Save(Path.Combine(certsPath, &quot;server.crt&quot;));
  </code></pre>
  <p><strong>Code snippet for starting up gRPC Server:</strong></p>
  <pre><code>// &quot;Server&quot; App
  ServerServiceDefinition serverDef = new ServerDefinitionFoo();
  var sslCredentials = GetCerts();
  var server = new Server()
  {
      Services = { serverDef },
      Ports = { new ServerPort(&quot;192.168.1.&quot;, port, sslCredentials) }
  };
  
  server.Start();
  </code></pre>
  <p><strong>Code snippet for setting up gRPC Client:</strong></p>
  <pre><code>// Client App
  static SslCredentials GetSslCredentials()
  {
      var certsFolder = Path.Combine(Environment.CurrentDirectory, &quot;Certs&quot;);
      var cacert = File.ReadAllText(Path.Combine(certsFolder, &quot;newca.crt&quot;));
      var cert = File.ReadAllText(Path.Combine(certsFolder, &quot;client.crt&quot;));
      var key = File.ReadAllText(Path.Combine(certsFolder, &quot;client.key&quot;));
  
      var keyPair = new KeyCertificatePair(cert, key);
      var Creds = new SslCredentials(cacert, keyPair);
      return Creds;
  }
  
  var sslCredentials = GetSslCredentials();
  var channel = new Channel(&quot;MACHINE-NAME:30052&quot;, sslCredentials);
  var apiProvider = new UtilitiesApi(new UtilitiesService.UtilitiesServiceClient(channel));
  var retVal = apiProvider.SomeServiceCall(&quot;Test Data&quot;);
  </code></pre>
  <p>The above scenario works successfully.</p>
  <p>If I <strong>change the following code snippet:</strong></p>
  <pre><code>var channel = new Channel(&quot;192.168.1.9:30052&quot;, sslCredentials);
  </code></pre>
  <p>I get the following exception on the client:</p>
  <blockquote>
  <p>Grpc.Core.RpcException: Status(StatusCode=&quot;Unavailable&quot;,
  Detail=&quot;failed to connect to all addresses&quot;,
  DebugException=&quot;Grpc.Core.Internal.CoreErrorDetailException:
  {&quot;created&quot;:&quot;@1605192569.522000000&quot;, &quot;description&quot;:&quot;Failed to pick
  subchannel&quot;,&quot;file&quot;</p>
  </blockquote>
  <p>I get the following error message (through logging) on the server console.</p>
  <blockquote>
  <p>E1112 09:49:29.510018 0
  T:\src\github\grpc\workspace_csharp_ext_windows_x64\src\core\tsi\ssl_transport_security.cc:1807:
  No match found for server name: 192.168.1.9.</p>
  </blockquote>
  <p>Should I be able to use IP Address when initating the client-server handshake?</p>
  <p>Thanks, JohnB</p>