Android-仅版本8(2.2 froyo)-ssl握手失败
下面的代码使用HTTP(API版本7和8)和HTTPS(API版本7)。 对于HTTPS(API版本8),我得到错误“java.io.IOException:SSL握手失败:SSL库中失败,通常是协议错误” 知道为什么只在版本8上吗 代码Android-仅版本8(2.2 froyo)-ssl握手失败,android,ssl,android-2.2-froyo,Android,Ssl,Android 2.2 Froyo,下面的代码使用HTTP(API版本7和8)和HTTPS(API版本7)。 对于HTTPS(API版本8),我得到错误“java.io.IOException:SSL握手失败:SSL库中失败,通常是协议错误” 知道为什么只在版本8上吗 代码 HttpURLConnection connection = null; BufferedReader brd = null; String line = "" ;
HttpURLConnection connection = null;
BufferedReader brd = null;
String line = "" ;
StringBuilder sb = new StringBuilder();
try {
//Set up the initial connection
//connection = (HttpURLConnection) new URL("http://MYSERVER.com").openConnection(); //Works
connection = (HttpURLConnection) new URL("https://MYSERVER.com").openConnection(); //error
connection.connect();
brd = new BufferedReader(new InputStreamReader(connection.getInputStream()));
sb = new StringBuilder();
while ((line = brd.readLine()) != null)
sb.append(line);
System.out.println(sb.toString());
} catch (IOException e) {
e.printStackTrace();
} finally{
//close the connection, set all objects to null
connection.disconnect();
brd = null;
sb = null;
connection = null;
}
完整错误堆栈
WARN/System.err(267):java.io.IOException:SSL握手失败:SSL库中失败,通常是协议错误
WARN/System.err(267):错误:140773F2:SSL例程:SSL23_GET_SERVER_HELLO:sslv3警报意外消息(外部/openssl/SSL/s23_clnt.c:599 0xaf076ad8:0x00000000)
位于org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.nativeconnect(本机方法)
位于org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:316)
位于org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.getSecureSocket(HttpConnection.java:168)
位于org.apache.harmony.luni.internal.net.www.protocol.https.HttpsURLConnectionImpl$HttpsEngine.connect(HttpsURLConnectionImpl.java:399)
位于org.apache.harmony.luni.internal.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:147)
谢谢,
纳拉亚南这里有一个解决方案,用户396259我面临着同样的问题,你成功了吗?