I have a Spring Boot 3.1 application with the following configuration:
spring:
ssl:
bundle:
pem:
my-client:
keystore:
certificate: "MIIKyAIBAzCCC..."
private-key: "keystore-password"
type: "PKCS12"
Note: The value of certificate is actually a keystore containing a root, an intermediate and a leaf certificate.
Running the applications results in the following exception:
Application run failed java.io.FileNotFoundException: /home/vcap/app/MIIKyAIBAzCCC...
Nowhere in the documentation is specified that it has to be a file resource.
Documentation link: https://spring.io/blog/2023/06/07/securing-spring-boot-applications-with-ssl
So my question is: how do I make the spring autoconfiguration work with an Base64 encoded keystore (in string format)?
In case you're looking for the autoconfiguration class, it's: org.springframework.boot.autoconfigure.ssl.SslProperties
According to the javadoc, the property could be the "content" or the "location" in PEM format.
There is nothing about the encoding of the content certificate in base64 and PKCS12 is not a PEM
Checking at the code that loads the keystore, you can see that the distinction between "content" or "location" is based on the first characters matching the usual header of PEM files
Note: You can see that the location expect and URI. If Java would support natively the
datascheme in url (Does it?), this should became possibleTo your answer: You cannot use autoconfigure with a PKCS12 encoded in base64 without some extra steps.