title: Problems with grpc connection using ssl
body: <p>I am currently new in grpc.
  I wanted to provide ssl for  my grpc server
  the javav code for starting looks like this:</p>
  <pre><code>InputStream publicKey = ServerStarter.class.getResourceAsStream(&quot;/my-public-key-cert.pem&quot;);
  InputStream privateKey = ServerStarter.class.getResourceAsStream(&quot;/my-private-key.pem&quot;);
  SslContext sslContext = GrpcSslContexts.forServer(publicKey, privateKey).build();
  Server server = NettyServerBuilder.forPort(5555)
                      .sslContext(sslContext)
                      .addService(new RedirectService())
                      .intercept(new AuthorizationInterceptor())
                      .build();
  server.start();
  </code></pre>
  <p>SSL certificates were generated with openssl. And here how openssl command looks like:</p>
  <pre><code>openssl req -x509 -newkey rsa:4096 -keyout ./grpc-server/src/main/resources/my-private-key.pem -out ./grpc-server/src/main/resources/my-public-key-cert.pem -days 365 -nodes -subj &quot;/CN=192.168.88.132&quot; -addext &quot;subjectAltName = DNS.1:192.168.88.132, DNS.2:localhost&quot;
  </code></pre>
  <p>Server runs fine.
  But I can't connect to server.
  My clients code looks like this:</p>
  <pre><code>InputStream certificate = GalamatClient.class.getResourceAsStream(&quot;/my-public-key-cert.pem&quot;);
  SslContext context = GrpcSslContexts.forClient().trustManager(certificate).build();
  ManagedChannel channel = NettyChannelBuilder.forTarget(&quot;192.168.88.132:5555&quot;)
                  .sslContext(context)
                  .build();
  GreetingServiceGrpc.GreetingServiceBlockingStub stub = GreetingServiceGrpc.newBlockingStub(channel)
  GreetingService.GreetingRequest request = GreetingService.GreetingRequest.newBuilder().setMessage(&quot;Hi&quot;).build();
  GreetingService.GreetingResponse response = stub.greet(request);
  channel.shutdownNow();
  </code></pre>
  <p>And when I try to run client next Error occurs:</p>
  <pre><code>Exception in thread &quot;main&quot; io.grpc.StatusRuntimeException: UNAVAILABLE: io exception
  Channel Pipeline: [SslHandler#0, ProtocolNegotiators$ClientTlsHandler#0, WriteBufferingAndExceptionHandler#0, DefaultChannelPipeline$TailContext#0]
      at io.grpc.stub.ClientCalls.toStatusRuntimeException(ClientCalls.java:262)
      at io.grpc.stub.ClientCalls.getUnchecked(ClientCalls.java:243)
      at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:156)
      at com.example.GreetingServiceGrpc$GreetingServiceBlockingStub.recognize(SpeechRecognitionGrpc.java:246)
      at com.example.main(Client.java:59)
  Caused by: javax.net.ssl.SSLHandshakeException: General OpenSslEngine problem
      at io.grpc.netty.shaded.io.netty.handler.ssl.ReferenceCountedOpenSslEngine.handshakeException(ReferenceCountedOpenSslEngine.java:1772)
      at io.grpc.netty.shaded.io.netty.handler.ssl.ReferenceCountedOpenSslEngine.wrap(ReferenceCountedOpenSslEngine.java:777)
      at javax.net.ssl.SSLEngine.wrap(SSLEngine.java:509)
      at io.grpc.netty.shaded.io.netty.handler.ssl.SslHandler.wrap(SslHandler.java:1079)
      at io.grpc.netty.shaded.io.netty.handler.ssl.SslHandler.wrapNonAppData(SslHandler.java:970)
      at io.grpc.netty.shaded.io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1443)
      at io.grpc.netty.shaded.io.netty.handler.ssl.SslHandler.decodeJdkCompatible(SslHandler.java:1275)
      at io.grpc.netty.shaded.io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1322)
      at io.grpc.netty.shaded.io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:501)
      at io.grpc.netty.shaded.io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:440)
      at io.grpc.netty.shaded.io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276)
      at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
      at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
      at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
      at io.grpc.netty.shaded.io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
      at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
      at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
      at io.grpc.netty.shaded.io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
      at io.grpc.netty.shaded.io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
      at io.grpc.netty.shaded.io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:714)
      at io.grpc.netty.shaded.io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:650)
      at io.grpc.netty.shaded.io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:576)
      at io.grpc.netty.shaded.io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)
      at io.grpc.netty.shaded.io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
      at io.grpc.netty.shaded.io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
      at io.grpc.netty.shaded.io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
      at java.lang.Thread.run(Thread.java:748)
  Caused by: java.security.cert.CertificateException: No subject alternative names matching IP address 192.168.88.132 found
      at sun.security.util.HostnameChecker.matchIP(HostnameChecker.java:168)
      at sun.security.util.HostnameChecker.match(HostnameChecker.java:94)
      at sun.security.ssl.X509TrustManagerImpl.checkIdentity(X509TrustManagerImpl.java:459)
      at sun.security.ssl.X509TrustManagerImpl.checkIdentity(X509TrustManagerImpl.java:440)
      at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:261)
      at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:144)
      at io.grpc.netty.shaded.io.netty.handler.ssl.OpenSslTlsv13X509ExtendedTrustManager.checkServerTrusted(OpenSslTlsv13X509ExtendedTrustManager.java:223)
      at io.grpc.netty.shaded.io.netty.handler.ssl.ReferenceCountedOpenSslClientContext$ExtendedTrustManagerVerifyCallback.verify(ReferenceCountedOpenSslClientContext.java:261)
      at io.grpc.netty.shaded.io.netty.handler.ssl.ReferenceCountedOpenSslContext$AbstractCertificateVerifier.verify(ReferenceCountedOpenSslContext.java:698)
      at io.grpc.netty.shaded.io.netty.internal.tcnative.SSL.readFromSSL(Native Method)
      at io.grpc.netty.shaded.io.netty.handler.ssl.ReferenceCountedOpenSslEngine.readPlaintextData(ReferenceCountedOpenSslEngine.java:596)
      at io.grpc.netty.shaded.io.netty.handler.ssl.ReferenceCountedOpenSslEngine.unwrap(ReferenceCountedOpenSslEngine.java:1203)
      at io.grpc.netty.shaded.io.netty.handler.ssl.ReferenceCountedOpenSslEngine.unwrap(ReferenceCountedOpenSslEngine.java:1325)
      at io.grpc.netty.shaded.io.netty.handler.ssl.SslHandler$SslEngineType$1.unwrap(SslHandler.java:201)
      at io.grpc.netty.shaded.io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1380)
      ... 21 more
      Suppressed: javax.net.ssl.SSLHandshakeException: error:1000007d:SSL routines:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED
          at io.grpc.netty.shaded.io.netty.handler.ssl.ReferenceCountedOpenSslEngine.sslReadErrorResult(ReferenceCountedOpenSslEngine.java:1288)
          at io.grpc.netty.shaded.io.netty.handler.ssl.ReferenceCountedOpenSslEngine.unwrap(ReferenceCountedOpenSslEngine.java:1249)
          ... 24 more
  </code></pre>
  <p>Error says that I don't provide needed Ip in subject alternative names:</p>
  <pre><code>No subject alternative names matching IP address 192.168.88.132 found
  </code></pre>
  <p>but I provided it in command of creation certificate.
  I will apreciate if you could help with that.</p>