如何使用 Spring 引导配置受信任的 SSL 密钥库?
How to Configure trusted SSL keystore with Spring boot?
想在我的 Spring Boot(1.3.2.RELEASE) 应用程序中引入 HTTPS 协议(可信证书)。
为此尝试了下一个 SSL 属性:
server.ssl.trust-store=classpath:key.jks
server.ssl.trust-store-password=pass
并出现错误:
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]
在该错误中,您可以看到应该传递 configureSslKeyStore。
当我尝试使用下一组更改启动应用程序时:
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
应用程序启动成功但无法访问 https:
所以现在我有几个问题:
- 这种行为的原因是什么,该协议不受支持?(证书是最新的并且没有过时)
- 没有冗余属性就无法配置受信任的证书是否正确?
- 有没有其他更方便的方式配置可信
SSL?
更新:
它是 JAR 文件,里面有证书 classpath:key.jks"".
原因在我的 .jks 文件中。它是以错误的方式生成的。
这里是link,您可以在其中找到正确的存储键结构。
想在我的 Spring Boot(1.3.2.RELEASE) 应用程序中引入 HTTPS 协议(可信证书)。 为此尝试了下一个 SSL 属性:
server.ssl.trust-store=classpath:key.jks
server.ssl.trust-store-password=pass
并出现错误:
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]
在该错误中,您可以看到应该传递 configureSslKeyStore。 当我尝试使用下一组更改启动应用程序时:
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
应用程序启动成功但无法访问 https:
所以现在我有几个问题:
- 这种行为的原因是什么,该协议不受支持?(证书是最新的并且没有过时)
- 没有冗余属性就无法配置受信任的证书是否正确?
- 有没有其他更方便的方式配置可信 SSL?
更新:
它是 JAR 文件,里面有证书 classpath:key.jks"".
原因在我的 .jks 文件中。它是以错误的方式生成的。 这里是link,您可以在其中找到正确的存储键结构。