Java gRPC:客户端无法连接到启用SSL的服务器

时间:2018-11-02 12:21:45

标签: java ssl grpc

我有一个启用了SSL的gRPC服务器(使用JDK作为ALPN提供程序)。 在客户端,我创建了一个通道并指定了我的信任库以包含服务器的公钥证书。这是我的操作方式(根据官方参考):

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

在JVM中启用ssl调试后,我得到以下提示:

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)

0 个答案:

没有答案