如何在SpringBoot启动期间引用认证文件

时间:2016-11-07 19:12:50

标签: spring file spring-boot resources launch

我有一个Mavenized项目(Web应用程序),我使用SpringBoot打包并运行它。我将其打包为战争,然后使用spring-boot:run maven目标启动它。 该应用程序调用几个需要证书的第三方供应商RESTful API。 我有来自供应商的cacert文件;对于我的localhost,我在我的文件系统上保存了cert文件,并在SpringBoot启动期间使用javax.net.ssl.trustStore命令行参数引用它[所以类似于:javax.net.ssl.trustStore=<path to cacert file on my file system>] 我现在决定将cacert文件保存在我的类路径中(所以在src / main / resources下的某个文件夹中)。 我希望SpringBoot在启动时加载此资源,并使用javax.net.ssl.trustStore系统属性引用它。 有人可以协助我怎么做?

1 个答案:

答案 0 :(得分:0)

以下是ssl属性列表(将这些添加到application.properties文件中):

server.ssl.ciphers= # Supported SSL ciphers.
server.ssl.client-auth= # Whether client authentication is wanted ("want") or needed ("need"). Requires a trust store.
server.ssl.enabled= # Enable SSL support.
server.ssl.enabled-protocols= # Enabled SSL protocols.
server.ssl.key-alias= # Alias that identifies the key in the key store.
server.ssl.key-password= # Password used to access the key in the key store.
server.ssl.key-store= # Path to the key store that holds the SSL certificate (typically a jks file).
server.ssl.key-store-password= # Password used to access the key store.
server.ssl.key-store-provider= # Provider for the key store.
server.ssl.key-store-type= # Type of the key store.
server.ssl.protocol=TLS # SSL protocol to use.
server.ssl.trust-store= # Trust store that holds SSL certificates.
server.ssl.trust-store-password= # Password used to access the trust store.
server.ssl.trust-store-provider= # Provider for the trust store.
server.ssl.trust-store-type= # Type of the trust store.

希望它有所帮助,参考:http://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html