简体   繁体   中英

How to Configure trusted SSL keystore with Spring boot?

Want to introduce HTTPS protocol (trusted certificate) to my Spring Boot(1.3.2.RELEASE) application. For this purpose tried next SSL properties:

server.ssl.trust-store=classpath:key.jks
server.ssl.trust-store-password=pass

and have the error:

Caused by: java.lang.IllegalArgumentException: Resource location must not be null
at org.springframework.util.Assert.notNull(Assert.java:115) ~[spring-core-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.util.ResourceUtils.getURL(ResourceUtils.java:131) ~[spring-core-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.configureSslKeyStore(TomcatEmbeddedServletContainerFactory.java:340) ~[spring-boot-1.3.2.RELEASE.jar:1.3.2.RELEASE]
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.configureSsl(TomcatEmbeddedServletContainerFactory.java:323) ~[spring-boot-1.3.2.RELEASE.jar:1.3.2.RELEASE]

In that error you can see that configureSslKeyStore should be passed. When I am trying to launch the application with next set of changes:

server.ssl.key-store=classpath:key.jks
server.ssl.key-store-password=pass
server.ssl.trust-store=classpath:key.jks
server.ssl.trust-store-password=pass

Application starts successfully but https is not reachable: 在此处输入图片说明

So now I have several questions:

  • What can be the reason of such behavior, that protocol is unsupported?(Certificate is fresh and not outdated)
  • Is it correctly that there is no way to configure trusted certificate without redundant properties?
  • Is there some other more convenient way to configure trusted SSL?

UPDATE:

It is JAR file and certificate exists inside of it classpath:key.jks"".

The reason was in my .jks file. It was generated in a wrong way. Here is the link where you can find the correct structure of storekeys.

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