1

Im trying to download website content from the website https://songbpm.com/tiesto/red+lights however due to the certificate issue the content is not being received The content will be later used to obtain the bpm of certain songs from an android app.

code for making the connection

AsyncHttpPost post = new AsyncHttpPost();
post.execute("https://songbpm.com/tiesto/red+lights");
TextView tv = (TextView)findViewById(R.id.textview1);
tv.setText("Hello,"+post.get().toString()+",");

async http post class as it is in a separate thread

byte[] result = null;
String str = "";
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(params[0]);
try {
     HttpResponse response = client.execute(post);
     StatusLine statusLine = response.getStatusLine();
    if(statusLine.getStatusCode() == HttpURLConnection.HTTP_OK){
        result = EntityUtils.toByteArray(response.getEntity());
        str = new String(result, "UTF-8");
    }
}
Meelan Lakhoo
  • 11
  • 1
  • 3

1 Answers1

2

I had the same problem a while ago. I used a workaround like this one: Trusting all certificates using HttpClient over HTTPS

After adding the MySSLSocketFactory it worked without a problem. So this might help you.

Note: This is not a very safe solution. Only use it for testing purposes.

Community
  • 1
  • 1
Hans1984
  • 796
  • 11
  • 24