Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

spring-boot executable war keystore not found

I build spring-boot executable war with ssl support. My application.properties file is:

server.port = 8443
server.ssl.key-store = classpath:keystore.jks
server.ssl.key-store-password = secret
server.ssl.key-password = another-secret

WAR file contains 'keystore.jks' file. But I get strange exception:

org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.boot.context.embedded.EmbeddedServletContainerException: Could not find key store classpath:keystore.jks

Caused by: java.io.FileNotFoundException: class path resource [keystore.jks] cannot be resolved to absolute file path because it does not reside in the file system: jar:file:/D:/projects/vi3na/vi3na.web/target/vi3na.war!/WEB-INF/classes!/keystore.jks

What does sign '!' mean in the path 'D:/projects/vi3na/vi3na.web/target/vi3na.war!/WEB-INF/classes!/keystore.jks'

like image 462
Igor Tytar Avatar asked Sep 30 '15 05:09

Igor Tytar


2 Answers

In my Spring Boot application I resolved this issue by placing .jks file into resource folder.

enter image description here

like image 173
Sazzad Hissain Khan Avatar answered Sep 22 '22 11:09

Sazzad Hissain Khan


Update: As a result of this enhancement request, the limitation described below no longer applies. Tomcat 8.0.28+ and 7.0.66+ can load a key store from within a jar file.

Original answer

I guess that you're using Tomcat as the embedded servlet container? As noted in the reference documentation, Tomcat does not currently support loading a keystore or trust store from within a jar:

Tomcat requires the key store (and trust store if you’re using one) to be directly accessible on the filesystem, i.e. it cannot be read from within a jar file.

You should move keystore.jks out of your jar and update server.ssl.key-store with its location on the file system.

like image 42
Andy Wilkinson Avatar answered Sep 25 '22 11:09

Andy Wilkinson