android - 主机名未经过验证 ANDROID

标签 android web-services socket.io ksoap2 ksoap

我正在使用 ksoap lib 来调用 webservice 。在某些情况下,服务运行正常,但在某些情况下,它给出的主机名未验证 下面是我调用 webservice 的代码。

 HttpTransportSE httpTransport = new HttpTransportSE(URL, MessageConstant.TIMEOUT_TIME);
            httpTransport.debug = true; // this is optional, use it if you don't want to use a packet sniffer to check what the sent message was (httpTransport.requestDump)
            httpTransport.call(SOAP_ACTION, envelope); // send request

这是我的日志猫

java.io.IOException: Hostname 'XXX.XX.XXX.XXX' was not verified
at libcore.net.http.HttpConnection.verifySecureSocketHostname(HttpConnection.java:223)
at libcore.net.http.HttpsURLConnectionImpl$HttpsEngine.connect(HttpsURLConnectionImpl.java:446)
at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:289)
at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:239)
at libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:80)
at libcore.net.http.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:165)
at org.ksoap2.transport.ServiceConnectionSE.connect(ServiceConnectionSE.java:76)
at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:152)
at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:95)

最佳答案

此链接有多种可能的原因;没有任何回复被标记为“已接受”:

您还应该看看这里:

One reason this can happen is due to a server configuration error. The server is configured with a certificate that does not have a subject or subject alternative name fields that match the server you are trying to reach. It is possible to have one certificate be used with many different servers.

For example, looking at the google.com certificate with openssl s_client -connect google.com:443 | openssl x509 -text you can see that a subject that supports *.google.com but also subject alternative names for *.youtube.com, *.android.com, and others. The error occurs only when the server name you are connecting to isn't listed by the certificate as acceptable.

关于android - 主机名未经过验证 ANDROID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19157710/

相关文章:

c# - .NET:DDD 和 ASMX,避免在代理类上使用多个命名空间

javascript - Socket.io 从 Node 中的多个套接字接收数据

rabbitmq - 当 "re"通过 socket.io 连接时,Node.js + socket.io + node-amqp 和队列 binginds

node.js - 实用或最佳的 socket.io 实现

当有人进入或离开某个区域时,Android 会收到通知

android - sqlite "insert or replace"是否与 AUTOINCREMENT 主键一起使用?

Android - 使用 while 循环停止线程

android - 如何为一系列表行而不是整个表创建内容提供者 URI

php - 如何为在同一台服务器上运行的不同进程使用不同的域名

javascript - 从 JavaScript Web 服务客户端发送 CORS POST 请求返回 http 405 错误