Java gRPC: клиент не может подключиться к серверу с включенным SSL - PullRequest
0 голосов
/ 02 ноября 2018

У меня есть сервер gRPC, работающий с включенным SSL (использующий JDK в качестве провайдера ALPN). На стороне клиента я создал канал и указал хранилище доверенных сертификатов для хранения сертификата открытого ключа сервера. Вот как я это сделал (по официальной ссылке):

Channel channel = NettyChannelBuilder.forAddress("localhost", 8080)
        .sslContext(GrpcSslContexts.forClient().trustManager(new File("conf/server.crt")).build()).build();

При включенной отладке ssl в JVM я получаю следующее:

grpc-default-worker-ELG-3-2, called closeOutbound()
grpc-default-worker-ELG-3-2, closeOutboundInternal()
grpc-default-worker-ELG-3-2, called closeInbound()
grpc-default-worker-ELG-3-2, fatal error: 80: Inbound closed before receiving peer's close_notify: possible truncation attack?
javax.net.ssl.SSLException: Inbound closed before receiving peer's close_notify: possible truncation attack?
grpc-default-worker-ELG-3-2, SEND TLSv1.2 ALERT:  fatal, description = internal_error
grpc-default-worker-ELG-3-2, Exception sending alert: java.io.IOException: writer side was already closed.
grpc-default-worker-ELG-3-2, called closeOutbound()
grpc-default-worker-ELG-3-2, closeOutboundInternal()
grpc-default-worker-ELG-3-2, called closeOutbound()
grpc-default-worker-ELG-3-2, closeOutboundInternal()

Исключения, которые я получаю:

Exception in thread "main" io.grpc.StatusRuntimeException: UNKNOWN
    at io.grpc.stub.ClientCalls.toStatusRuntimeException(ClientCalls.java:210)
    at io.grpc.stub.ClientCalls.getUnchecked(ClientCalls.java:191)
    at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:124)
    at com.videobet.grpc.helloworld.HelloWorldServiceGrpc$HelloWorldServiceBlockingStub.greet(HelloWorldServiceGrpc.java:139)
    at client.MyClient.main(MyClient.java:21)
Caused by: java.nio.channels.ClosedChannelException
    at io.netty.handler.ssl.SslHandler.channelInactive(...)(Unknown Source)
...