其他分享
首页 > 其他分享> > 主机名未通过验证ANDROID

主机名未通过验证ANDROID

作者:互联网

我正在使用kso​​ap lib调用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)

解决方法:

该链接可能有多种原因.没有一个响应被标记为“已接受”:

> java.io.IOException: Hostname was not verified

您还应该在这里查看:

  • 07001

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.

标签:ksoap2,android,socket-io,web-services,ksoap
来源: https://codeday.me/bug/20191013/1905388.html