我正在使用spring boot来对证书进行数字签名。这是我的代码段。
@Bean
public Wss4jSecurityInterceptor securityInterceptor() throws Exception {
Wss4jSecurityInterceptor securityInterceptor = new Wss4jSecurityInterceptor();
// set security actions
securityInterceptor.setSecurementActions("Timestamp Signature");
// sign the request
securityInterceptor.setSecurementPassword("password");
securityInterceptor.setSecurementSignatureCrypto(getCryptoFactoryBean().getObject());
securityInterceptor.setSecurementSignatureKeyIdentifier("DirectReference");
return securityInterceptor;
}
@Bean
public CryptoFactoryBean getCryptoFactoryBean() throws IOException {
CryptoFactoryBean cryptoFactoryBean = new CryptoFactoryBean();
cryptoFactoryBean.setKeyStorePassword("password");
cryptoFactoryBean.setKeyStoreLocation(new UrlResource("http://hostname/cert.p12"));
return cryptoFactoryBean;
}
我收到以下错误:
Caused by: java.io.FileNotFoundException: URL [http://hostname/cert.p12] cannot be resolved to absolute file path because it does not reside in the file system: http://hostname/cert.p12
at org.springframework.util.ResourceUtils.getFile(ResourceUtils.java:215)
at org.springframework.core.io.AbstractFileResolvingResource.getFile(AbstractFileResolvingResource.java:53)
at org.springframework.core.io.UrlResource.getFile(UrlResource.java:213)
at org.springframework.ws.soap.security.wss4j2.support.CryptoFactoryBean.getResourcePath(CryptoFactoryBean.java:91)
有没有办法在cryptoFactoryBean.setKeyStoreLocation中使用URL?
谢谢,