Spring-boot executable war storage not found

I am creating a spring-boot executable war with ssl support. My application.properties file:

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

The WAR file contains the keystore.jks file. But I get a 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 the sign '!' Mean on the way 'D: /projects/vi3na/vi3na.web/target/vi3na.war! / WEB-INF / classes! /keystore.jks'

+5
source share
2 answers

Update: As a result of this request for improvement, the restriction described below no longer applies. Tomcat 8.0.28+ and 7.0.66+ can load the keystore from the jar file.

Original answer

, Tomcat ? , Tomcat :

Tomcat , ( , ), , jar.

keystore.jks server.ssl.key-store .

+9

, Java KeyStore (JKS) application.properties :

1- JKS

jmendoza@jmendoza:~$ keytool -genkey -alias selfsigned_localhost_sslserver -keyalg RSA -keysize 2048 -validity 700 -keypass changeit -storepass changeit -keystore ssl-server.jks

2- JKS application.properties

server.port=8081
server.ssl.key-alias=electoralsystem-store
server.ssl.key-password=jmendoza
server.ssl.key-store=/home/jmendoza/IdeaProjects/dummy/config/electoralsystem-store.jks
server.ssl.key-store-provider=SUN
server.ssl.protocol=TLS
server.ssl.enabled-protocols=TLSv1.2

3-

https://localhost:8081/api/process

: , SSL :                            , " SSL-" ""> "".

+1

Source: https://habr.com/ru/post/1609555/


All Articles