gpt4 book ai didi

java - 未实现未连接的套接字

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:13:54 24 4
gpt4 key购买 nike

我必须使用 2 种身份验证访问网络服务。以下是我的方法。

创建了 MyCustomSSLSocketFactory 类。

  1. 加载 TrustManager
  2. 加载 keystore 管理器
  3. 如下创建 SSL 上下文和 SSL 套接字工厂。

我在调用 webservice 方法之前调用了这个类方法。

然后我做了如下:-

AxisProperties.setProperty("axis.socketSecureFactory",
"com.elipva.zephyr.twofa.util.MyCustomSSLSocketFactory");

Security.setProperty("ssl.SocketFactory.provider",
"com.elipva.zephyr.twofa.util.MyCustomSSLSocketFactory");


SSLContext context = SSLContext.getInstance(protocolVersion);
context.init(keyManagers, trustManagers, null);
SSLSocketFactory socketFactory = context.getSocketFactory();

URL url = new URL(urlString);
URLConnection connection = url.openConnection();
if (connection instanceof HttpsURLConnection) {
((HttpsURLConnection) connection)
.setSSLSocketFactory(sslSocketFactory);

connection.connect();
}

当我访问网络服务时,出现以下错误。

org.apache.axis2.AxisFault: Unconnected sockets not implemented
at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:203)
at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:76)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:400)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:225)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:435)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:402)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)

如果我遗漏了什么,请告诉我。

最佳答案

问题已解决,只需在 cacerts 文件中导入证书即可。

关于java - 未实现未连接的套接字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9924986/

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