gpt4 book ai didi

java - SAAJ 包括客户端证书

转载 作者:太空宇宙 更新时间:2023-11-04 14:48:18 24 4
gpt4 key购买 nike

我想通过 https 调用 Web 服务,并且需要包含客户端证书。我正在用 SAAJ 来做这件事

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

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

最佳答案

我创建

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

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

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

然后我设置了DefaultSSLSocketFactory

HttpsURLConnection.setDefaultSSLSocketFactory(sslcontext.getSocketFactory());

关于java - SAAJ 包括客户端证书,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24115156/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com