The code below works with HTTP (API version 7 and 8) and HTTPS (API version 7). For HTTPS (API version 8) I get the error message "java.io.IOException: SSL connection establishment error: error in SSL library, usually protocol error"
Any idea why only on version 8?
The code...
HttpURLConnection connection = null;
BufferedReader brd = null;
String line = "" ;
StringBuilder sb = new StringBuilder();
try {
connection = (HttpURLConnection) new URL("https://MYSERVER.com").openConnection();
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{
connection.disconnect();
brd = null;
sb = null;
connection = null;
}
Full stack of errors
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( )
at 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)
,