1

我想通过 https 调用 Web 服务,我需要包含客户端证书。我正在使用 SAAJ

SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();
conn = soapConnectionFactory.createConnection();
URL endpoint = new URL(urlEndPoint);
SOAPMessage response = conn.call(msg, endpoint);

但是如何包含客户端证书?

4

1 回答 1

0

我创造

KeyManagerFactory kmf = csm.getKeyManagerFactory();
TrustManagerFactory tmf = csm.getTrustManagerFactory();

SSLContext sslcontext = SSLContexts.custom().useProtocol("SSL").build();

sslcontext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), new SecureRandom());

然后我 setDefaultSSLSocketFactory

HttpsURLConnection.setDefaultSSLSocketFactory(sslcontext.getSocketFactory());
于 2014-06-10T05:49:32.183 回答