Storing JKS files in Spring Cloud Config Sever

A customer asked me how they can store a JKS file with certificates in a spring cloud config server, retrieve it on application startup and use it to setup a a Java SSLContext for doing mutual TLS with a backend system, that was using self signed certificates.

The config server can’t store binary files, so you have to first encode the JKS file as a base64 string, put in the config server then pull it at startup with regular Spring @Value annotation which is then used to setup the context. I created a sample application which you can find at https://github.com/asaikali/mtls-demo