【发布时间】:2016-10-16 01:18:41
【问题描述】:
服务器上的io和android上的客户端。
只要我启用 HTTP(S) SSL,它就会在 android 上导致连接错误(但是如果禁用它可以正常工作)
我尝试在 Android 上实现 HTTPS 连接,参考 Github 上的示例如下:
opts = new IO.Options();
opts.sslContext = mySSLContext;
opts.hostnameVerifier = myHostnameVerifier;
socket = IO.socket("https://mychat.url", opts);
还有这个
SSLContext mySSLContext = SSLContext.getInstance("TLS");
mySSLContext.init(null, null, null);
还有这个
myHostnameVerifier = new HostnameVerifier() {
@Override
public boolean verify(String hostname, SSLSession session) {
return true;
}
});
在套接字传输过程中仍然收到错误消息
io.socket.engineio.client.EngineIOException: xhr poll error
javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
使用 HTTPS 协议实现 socket io 连接需要什么?
【问题讨论】:
-
我不确定,但可能是信任管理器问题,请查看developer.android.com/training/articles/security-ssl.html
-
@Apurva 谢谢你,我自己解决了。是的,这是 trustManager 问题。
标签: android ssl https socket.io tls1.2