0

i am using below code to get the response from https url

code:

URL url = new URL(sURL);

HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setRequestMethod( "POST" );
urlConnection.setRequestProperty( "Content-Type", "application/x-www-form-urlencoded");
urlConnection.setRequestProperty( "charset", "utf-8");
urlConnection.setUseCaches( false );
urlConnection.setDoOutput(true);


//out = new BufferedOutputStream(urlConnection.getOutputStream());

try( DataOutputStream wr = new DataOutputStream( urlConnection.getOutputStream())) {
wr.writeBytes(getQuery(postParameters));
}

BufferedReader in = new BufferedReader(
    new InputStreamReader(urlConnection.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();

while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();

//                HttpResponse r = client.execute(post);
int status = urlConnection.getResponseCode();
Log.i(TAG, "Got a response back from the server: " + status);
if (status == 200) {
//HttpEntity e = r.getEntity();
jsondatastring = inputLine;//EntityUtils.toString(e);
jarray = new JSONArray(jsondatastring);
jsonObject = jarray.getJSONObject(0);
Log.i(TAG, "Got the JSON data . returning the json object");
}

having error javax.net.ssl.SSLHandshakeException: SSL handshake aborted: ssl=0xb91ab9d8: I/O error during system call, Connection reset by peer

How can make successfull connection to Https urls ?

any help or ideas will be well appreciated.

Thanks

Manoj
  • 641
  • 4
  • 9

0 Answers0