Given I have file in c:\\path\\to\\file\\keystore.jks
and my application.properties file contains server.ssl.key-store=c:\\path\\to\\file\\keystore.jks
I get the following exception java.io.FileNotFoundException: C:\\Windows\\Temp\\tomcat.2910824355292831382\\file:\\c:\\path\\to\\file\\keystore.jks (The filename, directory name, or volume label syntax is incorrect)
What is the correct way to specify the path?
Do not rely on absolute paths. Put the file into same directory as Spring Boot JAR and add this line into your application.properties:
server.ssl.key-store=file:keystore.jks
Second option is to pass system variable to -Dserver.ssl.key-store=file:keystore.jks
Below worked for me with Tomcat 8.5.2:
Windows:
server:
ssl:
key-store: file:C:\<complete file path with extension>
Linux:
server:
ssl:
key-store: file:/J2EE/<complete file path with extension>
This worked for me when I made these changes:
Check which version of tomcat is being used by spring boot. According to this github issue tomcat versions less than 7.0.66 relativize the server.ssl.key-store setting.
Putting file:
didn't work for relative paths for me. In summary:
If you put the keystore in your resources, you do this:
key-store: classpath:keystore.jks
However, if you try this:
key-store: file:keystore.jks
you will get:
java.lang.IllegalStateException: no valid keystore
So, instead, just do this:
key-store: keystore.jks
Strangely, if you supply the full path (not relative path), then file:
will still work.
Just use quotes for keystore file path
server:
port: 8443
ssl:
enabled: true
key-store: "/path/to/keystore/keystore.jks"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.