Securing gRPC service-to-service communications with mTLS

TlsServerCredentials.ClientAuth clientAuth = TlsServerCredentials.ClientAuth.NONE;TlsServerCredentials.Builder tlsBuilder = TlsServerCredentials.newBuilder().keyManager(Utils.getKeyManagers(“<path-to-keystore>/carparkserver-keystore.jks”,“<keystore-password>”.toCharArray(),“JKS”)).trustManager(Utils.getTrustManagers(“<path-to-truststore>/carparkserver-truststore.jks”,“<truststore-password>”.toCharArray(),“JKS”)).clientAuth(clientAuth);Server server = Grpc.newServerBuilderForPort(40404, tlsBuilder.build()).addService(new CarParkServiceImpl()).build();
TlsServerCredentials.ClientAuth clientAuth = TlsServerCredentials.ClientAuth.REQUIRE;
TlsChannelCredentials.Builder tlsBuilder = TlsChannelCredentials.newBuilder();tlsBuilder.keyManager(Utils.getKeyManagers(“scripts/carparkclient-keystore.jks”,“111111”.toCharArray(), “JKS”));tlsBuilder.trustManager(Utils.getTrustManagers(“scripts/carparkclient-truststore.jks”,“111111”.toCharArray(), “JKS”));ManagedChannel channel = Grpc.newChannelBuilderForAddress(“localhost”, 40404, tlsBuilder.build()).build();

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store