java 如何使用 Spring Boot 配置受信任的 SSL 密钥库?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/44958116/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to Configure trusted SSL keystore with Spring boot?
提问by Speise
Want to introduce HTTPS protocol (trusted certificate) to my Spring Boot(1.3.2.RELEASE) application. For this purpose tried next SSL properties:
想在我的 Spring Boot(1.3.2.RELEASE) 应用中引入 HTTPS 协议(可信证书)。为此,尝试了下一个 SSL 属性:
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 configureSslKeyStoreshould be passed. When I am trying to launch the application with next set of changes:
在该错误中,您可以看到应该传递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
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?
- 这种行为的原因是什么,该协议不受支持?(证书是新的,没有过时)
- 没有冗余属性就无法配置可信证书是否正确?
- 有没有其他更方便的方法来配置受信任的 SSL?
UPDATE:
更新:
It is JAR file and certificate exists inside of it classpath:key.jks"".
它是 JAR 文件,证书存在于其中 classpath:key.jks""。