'TLS/SSL between microservices, api-gateway and a config-server in Spring Boot?
I have multiple microservices that get its initial configurations off a config-server, and the API requests should pass through an api-gateway first. I've managed to enable HTTPS on each microservice with server.ssl.* along with a self-signed keystore generated using keytool. Accessing each microservice directly through https is no problem but I ran into a lot of errors when I try to go through the api-gateway first. All the errors were either unable to find valid certification path to requested target, not an SSL/TLS record or trustanchors parameter must be non-empty even if I add the various server.ssl.trust-store properties.
I've bypassed it for now by adding the following lines to the main class of my api-gateway:
ClassPathResource resource = new ClassPathResource("SSL.jks");
try {
System.setProperty("javax.net.ssl.trustStore", Paths.get(resource.getURI()).toString());
} catch (IOException e) {
e.printStackTrace();
}
System.setProperty("javax.net.ssl.trustStoreType", "jks");
System.setProperty("javax.net.ssl.trustStorePassword","password");
I would like to know if there is a better way to do this instead of "hard-coding" it like this. I also haven't added HTTPS to the config-server but I assume I will end up having to do this. I'm also not understanding how I can "auto-import" the certificates (if that's how I have to do it) for it to work in production? Importing the self-signed certs to my java only makes sense for my local machine.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
