How do I specify local file path to my ssl keystore file in spring application.properties?

16,250

Solution 1

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.

Solution 2

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

Solution 3

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>
Share:
16,250

Related videos on Youtube

SebS
Author by

SebS

Updated on July 09, 2022

Comments

  • SebS
    SebS almost 2 years

    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?

    • Boris the Spider
      Boris the Spider almost 8 years
      It's a URI! You need to use file://.
  • SebS
    SebS almost 8 years
    I have tried quotes this did not make a difference.
  • SebS
    SebS almost 8 years
    It always prepends the c\windows\temp\tomcat...... before. I think this is the server.tomcat.basedir path.
  • SebS
    SebS about 6 years
    Tomcat version 8.5 cannot be used with Java6.