Skip to content

Instantly share code, notes, and snippets.

@davidraleigh
Created February 19, 2018 23:53
Show Gist options
  • Save davidraleigh/9f31f9a2fd27c71a473159d4b911a6e7 to your computer and use it in GitHub Desktop.
Save davidraleigh/9f31f9a2fd27c71a473159d4b911a6e7 to your computer and use it in GitHub Desktop.
how to run java grpc with ssl and not have failures

And just for proof that the certificates aren't the problem here's an example of the same exact certificate working with Java:

FROM openjdk:8-jdk

WORKDIR /opt

RUN git clone https://github.com/EchoParkLabs/grpc-java.git --branch lets-e --depth 1

WORKDIR /opt/grpc-java/examples

RUN ./gradlew installDist

RUN openssl req -nodes -newkey rsa:2048 -x509 -days 365 -keyout server.key -out server.crt -subj "/C=US/ST=California/L=Los Angeles/O=Echo Park Labs/OU=Software/CN=echoparklabs.io"

ENV GRPC_KEY /opt/grpc-java/examples/server.key
ENV GRPC_CHAIN /opt/grpc-java/examples/server.crt

CMD ./build/install/examples/bin/route-guide-server

To test the above, run these commands in one terminal:

sudo docker build --no-cache -t test-java .
sudo docker run -it --name="test-container" test-java

And from second terminal:

sudo docker exec -it test-container /bin/bash -c "./build/install/examples/bin/route-guide-client"

All of the tests run without any problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment