Can someone give me an example with grpc-java and ssl ?

4 642 просмотра
Перейти к первому непрочитанному сообщению

youngy...@gmail.com

не прочитано,
7 янв. 2016 г., 22:10:5907.01.2016
– grpc.io
Can someone give me an example with grpc-java and ssl ?

My code returns this error

io.grpc.StatusRuntimeException: UNKNOWN
at io.grpc.Status.asRuntimeException(Status.java:430)
at io.grpc.stub.ClientCalls.getUnchecked(ClientCalls.java:156)
at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:106)
at ex.grpc.GreeterGrpc$GreeterBlockingStub.sayHello(GreeterGrpc.java:109)
at com.chinark.api.helloworld.HelloWorldClient.greet(HelloWorldClient.java:45)
at com.chinark.api.helloworld.HelloWorldClient.main(HelloWorldClient.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Caused by: java.lang.Exception: Failed ALPN negotiation: Unable to find compatible protocol.
at io.grpc.netty.ProtocolNegotiators$BufferUntilTlsNegotiatedHandler.userEventTriggered(ProtocolNegotiators.java:400)
at io.netty.channel.ChannelHandlerInvokerUtil.invokeUserEventTriggeredNow(ChannelHandlerInvokerUtil.java:75)
at io.netty.channel.DefaultChannelHandlerInvoker.invokeUserEventTriggered(DefaultChannelHandlerInvoker.java:135)
at io.netty.channel.AbstractChannelHandlerContext.fireUserEventTriggered(AbstractChannelHandlerContext.java:149)
at io.netty.channel.ChannelInboundHandlerAdapter.userEventTriggered(ChannelInboundHandlerAdapter.java:108)
at io.netty.channel.ChannelHandlerInvokerUtil.invokeUserEventTriggeredNow(ChannelHandlerInvokerUtil.java:75)
at io.netty.channel.DefaultChannelHandlerInvoker.invokeUserEventTriggered(DefaultChannelHandlerInvoker.java:135)
at io.netty.channel.AbstractChannelHandlerContext.fireUserEventTriggered(AbstractChannelHandlerContext.java:149)
at io.netty.handler.ssl.SslHandler.setHandshakeSuccess(SslHandler.java:1240)
at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1067)
at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:965)
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:327)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:230)
at io.netty.channel.ChannelHandlerInvokerUtil.invokeChannelReadNow(ChannelHandlerInvokerUtil.java:83)
at io.netty.channel.DefaultChannelHandlerInvoker.invokeChannelRead(DefaultChannelHandlerInvoker.java:153)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:157)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:946)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:125)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:510)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:467)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:381)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:353)
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:742)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)


Eric Anderson

не прочитано,
8 янв. 2016 г., 11:48:5808.01.2016
– youngy...@gmail.com, grpc.io
Caused by: java.lang.Exception: Failed ALPN negotiation: Unable to find compatible protocol.

grpc-java wasn't able to negotiate HTTP/2. Are you sure you're hitting the right server and that it supports HTTP/2 and ALPN? If you are using jetty_alpn instead of tcnative then the problem could be the server only supports NPN.

Are you using tcnative or jetty_alpn? What language is the grpc server in? Are you using a reverse proxy?



--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+unsubscribe@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/a6374ac9-ead3-4578-a094-74f2ad8b0ad4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Young You

не прочитано,
9 янв. 2016 г., 04:57:5309.01.2016
– grpc.io, youngy...@gmail.com

I use jetty_alpn with jdk8, both client and server. And I do not use a proxy.

在 2016年1月9日星期六 UTC+8上午12:48:58,Eric Anderson写道:
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.

Eric Anderson

не прочитано,
11 янв. 2016 г., 15:04:1711.01.2016
– Young You, grpc.io
Make sure that any Netty SslContexts you provide have been passed through GrpcSslContexts (as described in the docs for NettyServerBuilder.sslContext).

If you aren't creating a SslContext manually today (and instead using useTransportSecurity), then I'm not immediately certain what is wrong. Sharing some code snippets for the ManagedChannelBuilder and ServerBuilder configuration would then be helpful.

To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+unsubscribe@googlegroups.com.

To post to this group, send email to grp...@googlegroups.com.

Young You

не прочитано,
13 янв. 2016 г., 04:35:2813.01.2016
– grpc.io
// Server
SslContext sslContext =  SslContextBuilder.forServer(
      new File("/Users/u/Desktop/api.grpc/src/main/resources/server.crt"),
      new File("/Users/u/Desktop/api.grpc/src/main/resources/private_key_pkcs8.pem"))
      .build();

server = NettyServerBuilder.forPort(port).sslContext(sslContext)
      .addService(GreeterGrpc.bindService(new GreeterImpl())).build()
      .start();

// Client
SslContext sslContext = SslContextBuilder.forClient().trustManager(new File(
                  "/Users/u/Desktop/api.grpc/src/main/resources/server.crt")).build();
      channel = NettyChannelBuilder.forAddress(host, port)
            .sslContext(sslContext)
            .build();
      blockingStub = GreeterGrpc.newBlockingStub(channel);

Both server and client do not work, I have tried with another client and server written in Ruby.


在 2016年1月8日星期五 UTC+8上午11:10:59,Young You写道:

Eric Anderson

не прочитано,
13 янв. 2016 г., 14:44:4113.01.2016
– Young You, grpc.io
Yep, you need to use GrpcSslContexts:
GrpcSslContexts.forClient().trustManager(...).build();
GrpcSslContexts.forServer(new File...).build();

Alternatively, you could use GrpcSslContexts.configure(...), but I'd suggest the easier forms above.

--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+unsubscribe@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.

Young You

не прочитано,
14 янв. 2016 г., 03:13:3214.01.2016
– grpc.io, youngy...@gmail.com
It works! Thank you very much!

在 2016年1月14日星期四 UTC+8上午3:44:41,Eric Anderson写道:
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.

To post to this group, send email to grp...@googlegroups.com.

karthik....@mtap.in

не прочитано,
16 авг. 2017 г., 06:18:1116.08.2017
– grpc.io, youngy...@gmail.com
Since Netty can't be used in Android, how it should be done in an Android Client? I couldn't find any useful example.

Eric Gribkoff

не прочитано,
16 авг. 2017 г., 11:31:4516.08.2017
– karthik....@mtap.in, youngy...@gmail.com, grpc.io
TLS is on by default for OkHttp channels. See our android-interop-test app for an example of how to create a secure connection using a test certificate, or just remove the call to ManagedChannel.usePlaintext(true) from this line in our Android Hello World app to have it use TLS when connecting.

Eric


To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+unsubscribe@googlegroups.com.

To post to this group, send email to grp...@googlegroups.com.
Ответить всем
Отправить сообщение автору
Переслать
0 новых сообщений