简体   繁体   中英

Spring Boot Application SSL property configuration: getKeyStorePassword before setKeyStorePassword

While trying to configure HTTPS/SSL functionality with spring boot and tomcat, I began to see this error:

Caused by: java.lang.IllegalArgumentException: Invalid keystore format
        at org.apache.tomcat.util.net.AbstractJsseEndpoint.createSSLContext(AbstractJsseEndpoint.java:116)
        at org.apache.tomcat.util.net.AbstractJsseEndpoint.initialiseSsl(AbstractJsseEndpoint.java:87)
        at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:225)
        at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:1150)
        at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:591)
        at org.apache.catalina.connector.Connector.startInternal(Connector.java:1018)
        ... 22 common frames omitted

Digging further, I saw the order in which the class SSL.java was being populated ( SSL.java is a basic POJO for configuration). The order in which the POJO was accessed for values was alarming. I saw "get" calls before "set" calls (specifically getKeyStorePassword before setKeyStorePassword ). This can't be good!

This seems like a really odd spring error in which it races against itself to set and get values. In this case, SSL configuration fails even though the correct values are eventually in place because they were ACCESSED before they were SET. Can someone highlight why this is the case and potential work arounds?

We are using Spring 1.5.12 and can confirm that all the configuration was correct.

Strangely, this seemed to be a POM/Maven issue.

By setting our resource filtering to false, the application started to set all of its variables in proper order.

<resource>
   <directory>src/main/java/resources</directory>
   <filtering>false</filtering>
</resource>

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM