io.grpc.netty.shaded.io.netty.handler.ssl.SslProvider Java Examples
The following examples show how to use
io.grpc.netty.shaded.io.netty.handler.ssl.SslProvider.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ShadingTest.java From grpc-nebula-java with Apache License 2.0 | 6 votes |
@Test public void tcnative() throws Exception { server = NettyServerBuilder.forPort(0) .useTransportSecurity(TestUtils.loadCert("server1.pem"), TestUtils.loadCert("server1.key")) .addService(new SimpleServiceImpl()) .build().start(); channel = NettyChannelBuilder .forAddress("localhost", server.getPort()) .sslContext( GrpcSslContexts.configure(SslContextBuilder.forClient(), SslProvider.OPENSSL) .trustManager(TestUtils.loadCert("ca.pem")).build()) .overrideAuthority("foo.test.google.fr") .build(); SimpleServiceBlockingStub stub = SimpleServiceGrpc.newBlockingStub(channel); assertThat(SimpleResponse.getDefaultInstance()) .isEqualTo(stub.unaryRpc(SimpleRequest.getDefaultInstance())); }
Example #2
Source File: ShadingTest.java From grpc-java with Apache License 2.0 | 6 votes |
@Test public void tcnative() throws Exception { server = NettyServerBuilder.forPort(0) .useTransportSecurity(TestUtils.loadCert("server1.pem"), TestUtils.loadCert("server1.key")) .addService(new SimpleServiceImpl()) .build().start(); channel = NettyChannelBuilder .forAddress("localhost", server.getPort()) .sslContext( GrpcSslContexts.configure(SslContextBuilder.forClient(), SslProvider.OPENSSL) .trustManager(TestUtils.loadCert("ca.pem")).build()) .overrideAuthority("foo.test.google.fr") .build(); SimpleServiceBlockingStub stub = SimpleServiceGrpc.newBlockingStub(channel); assertThat(SimpleResponse.getDefaultInstance()) .isEqualTo(stub.unaryRpc(SimpleRequest.getDefaultInstance())); }
Example #3
Source File: GrpcConfig.java From flair-engine with Apache License 2.0 | 5 votes |
private SslContextBuilder getSslContextBuilder() { log.info("Grpc config: Configuring ssl cert {} key {} trust {}", grpcProperties.getTls().getCertChainFile(), grpcProperties.getTls().getPrivateKeyFile(), grpcProperties.getTls().getTrustCertCollectionFile()); SslContextBuilder sslClientContextBuilder = SslContextBuilder.forServer( new File(grpcProperties.getTls().getCertChainFile()), new File(grpcProperties.getTls().getPrivateKeyFile()) ); if (grpcProperties.getTls().getTrustCertCollectionFile() != null) { sslClientContextBuilder.trustManager(new File(grpcProperties.getTls().getTrustCertCollectionFile())); sslClientContextBuilder.clientAuth(ClientAuth.REQUIRE); } return GrpcSslContexts.configure(sslClientContextBuilder, SslProvider.OPENSSL); }
Example #4
Source File: BrokerServer.java From gcp-token-broker with Apache License 2.0 | 5 votes |
private SslContextBuilder getSslContextBuilder() { String certChainFilePath = AppSettings.getInstance().getString(AppSettings.TLS_CERTIFICATE_PATH); String privateKeyFilePath = AppSettings.getInstance().getString(AppSettings.TLS_PRIVATE_KEY_PATH); SslContextBuilder sslClientContextBuilder = SslContextBuilder.forServer( new File(certChainFilePath), new File(privateKeyFilePath)); return GrpcSslContexts.configure( sslClientContextBuilder, SslProvider.OPENSSL); }