在 spring.application 中,我指定了 keystore 名称和密码。 我想使用来自 java security 的 Signature.sign() 对一些数据进行签名,但为此我需要 Keystore。有没有办法获取 Spring 管理的 keystore bean,或者我是否必须创建自己的 keystore ,即使它已被 spring 使用?
最佳答案
你可以直接使用
@Autowired
private KeyStore keyStore;
如果你像这样在 XML/Java 配置中正确配置它
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:crypt="http://springcryptoutils.com/schema/crypt"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
http://springcryptoutils.com/schema/crypt http://springcryptoutils.com/schema/crypt.xsd">
<crypt:keystore id="keystore"
location="somePath}"
password="somePassword"/>
</beans>
关于java - Spring keystore bean,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44285426/