3

I'm trying to fetch YouTube Channel Videos and I'm getting an exception.

javax.net.ssl.SSLPeerUnverifiedException: No peer certificate

Below is my Code.

strURL= https://www.googleapis.com/youtube/v3/search?key={your_key_here}&channelId={channel_id_here}&part=snippet,id&order=date&maxResults=20 

@Override
protected String doInBackground(Void... params) {

    try {
        HttpClient httpClient = new DefaultHttpClient();

        HttpPost httpPost = new HttpPost(strURL);

        // Response from the Http Request
        HttpResponse response = httpClient.execute(httpPost);

        StatusLine statusLine = response.getStatusLine();

        // Check the Http Request for success.
        if(statusLine.getStatusCode() == HttpStatus.SC_OK) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            response.getEntity().writeTo(byteArrayOutputStream);

            content = byteArrayOutputStream.toString();
            byteArrayOutputStream.close();

        } else {
            Log.w("HTTP1:", statusLine.getReasonPhrase());
            response.getEntity().getContent().close();
            throw new IOException(statusLine.getReasonPhrase());
        }
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    } catch (ClientProtocolException e) {
        Log.w("HTTP2:",e);
        content = e.getMessage();
        error = true;
    } catch (IOException e) {
        Log.w("HTTP3:", e);
        content = e.getMessage();
        error = true;
    }

    return content;
}
Michael Benjamin
  • 346,931
  • 104
  • 581
  • 701
Farrakh Javed
  • 153
  • 12
  • Check this [SO question](http://stackoverflow.com/questions/17159657/javax-net-ssl-sslpeerunverifiedexception-no-peer-certificate), it might help you solve you SSL issue. – Mr.Rebot Aug 10 '16 at 07:14

0 Answers0