![](/img/trans.png)
[英]Attach client certificate to web service call based on stubs created with wsdl2java
[英]attach certificate with web service request in java
我必须在java.so中为soap web服务创建客户端代码,该代码具有输入作为基本身份验证和ssl证书。 我找不到通过邮寄请求附加证书的方法。能告诉我如何通过邮寄请求附加证书和密码吗?
如果您使用的是apache CXF,此代码可能会帮助您:
Client client = ClientProxy.getClient(service);
HTTPConduit httpConduit = (HTTPConduit) client.getConduit();
TLSClientParameters tlsConfig = new TLSClientParameters();
try {
//Set up the keyStore for CXF
InputStream keyStoreInputStream = new FileOrClasspathResource(keyStorePath).openStream();
KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
keyStore.load(keyStoreInputStream, keyStorePassword.toCharArray());
TrustManagerFactory trustFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
trustFactory.init(keyStore);
TrustManager[] tm = trustFactory.getTrustManagers();
tlsConfig.setTrustManagers(tm);
} catch (Exception e) {
log.error("Couldn't initialize keyStore with name " + keyStorePath, e);
}
httpConduit.setTlsClientParameters(tlsConfig);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.