握手失败的棒棒糖 [英] Handshake fail on Lollipop
问题描述
我试图做一个HTTP POST,但我得到两个不同的错误:
I'm trying to do a HTTP POST but I get two different errors:
javax.net.ssl.SSLHandshakeException: Handshake failed
net.ssl.SSLPeerUnverifiedException: No peer certificate
我固定在没有同行证书错误通过变通方法如下定义:的http://计算器。 COM / A /四百二十五万四千四百一十九分之四百八十三万七千二百三十零
I fixed the No peer certificate error through a workaround as specified here: http://stackoverflow.com/a/4837230/4254419
但而修正错误,它抛出一个新的错误,而不是,这就是握手失败
but while that fixes the error, it throws a new error instead, which is Handshake failed
我知道这不是安全,我不在乎,这不是进行生产,所以我不太关心的安全性。是否有一个修复此问题?
I know it's not safe and I don't care, it's not for production so I care less about security. Is there a fix for this issue?
推荐答案
我有同样的问题。
我发现了一个链接的https://$c$c.google .COM / p /安卓/问题/细节ID = 88313 在那里我发现了一个code:
I had the same problem. I found a link https://code.google.com/p/android/issues/detail?id=88313 where I found a code:
public class MySSLSocketFactory extends SSLSocketFactory {
SSLContext sslContext = SSLContext.getInstance("TLS");
...
@Override
public Socket createSocket(Socket socket, String host, int port, boolean autoClose) throws IOException, UnknownHostException {
final SSLSocket sslSocket = (SSLSocket) sslContext.getSocketFactory().createSocket(socket, host, port, autoClose);
sslSocket.setEnabledCipherSuites(sslSocket.getSupportedCipherSuites());
return sslSocket;
}
@Override
public Socket createSocket() throws IOException {
final SSLSocket sslSocket = (SSLSocket) sslContext.getSocketFactory().createSocket();
sslSocket.setEnabledCipherSuites(sslSocket.getSupportedCipherSuites());
return sslSocket;
}
}
您可以使用 MySSLSocketFactory
的code从您所提供的链接,但你需要重写两个方法的createSocket
正如我上面写的。
此外,它不是最好的解决方案,可以在以后有一些安全问题,因为连接它可以使用一些旧的密码算法。
You can use code of MySSLSocketFactory
from the link you've provided but you need to override two methods createSocket
as I've wrote above.
Also it's not the best solution you can have some security issue later, because for connection it can use some old cipher algorithm.
希望这有助于。
这篇关于握手失败的棒棒糖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!