I have exceptions while login into a https web site using HttpsURLConnection
after updating to Android 5.0 lollipop
. (It worked well in android 4.4 kitkat)
05-08 02:18:12.277 32344-32482/com.soonoo.mobilecampus E/INFO﹕ javax.net.ssl.SSLHandshakeException: Handshake failed
I've read the article about android 5.0's changes. (http://developer.android.com/about/versions/android-5.0-changes.html#ssl)
It seems that I should add some cipher suites required by a server.
Can anyone please give me some advice/code about how to add cipher suites to HttpsURLConnection
? I tried below answer but didn't work for me...
(Which Cipher Suites to enable for SSL Socket?)
I used below code to connect:
HttpsURLConnection con = (HttpsURLConnection) new URL(Sites.LOGIN_URL).openConnection();
con.setRequestMethod("POST");
con.setRequestProperty("Content-length", String.valueOf(loginQuery.length()));
con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
con.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0;Windows98;DigExt)");
con.setDoOutput(true);
con.setDoInput(true);
DataOutputStream output = new DataOutputStream(con.getOutputStream());
output.writeBytes(loginQuery);
output.close();