Safely fixing: javax.net.ssl.SSLPeerUnverifiedException: No peer certificate Safely fixing: javax.net.ssl.SSLPeerUnverifiedException: No peer certificate android android

Safely fixing: javax.net.ssl.SSLPeerUnverifiedException: No peer certificate


It turns out my code was fine and the problem was that the server was not returning the full certificate chain. For more information see this SO post and this superuser post:

SSL certificate is not trusted - on mobile only

https://superuser.com/questions/347588/how-do-ssl-chains-work


Try below code :-

        BasicHttpResponse httpResponse = null;        HttpPost httppost = new HttpPost(URL);        HttpParams httpParameters = new BasicHttpParams();        // Set the timeout in milliseconds until a connection is        // established.        int timeoutConnection = ConstantLib.CONNECTION_TIMEOUT;        HttpConnectionParams.setConnectionTimeout(httpParameters,                timeoutConnection);        // Set the default socket timeout (SO_TIMEOUT)        // in milliseconds which is the timeout for waiting for data.        int timeoutSocket = ConstantLib.CONNECTION_TIMEOUT;        HttpConnectionParams                .setSoTimeout(httpParameters, timeoutSocket);        DefaultHttpClient httpClient = new DefaultHttpClient(                httpParameters);        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();        nameValuePairs.add(new BasicNameValuePair(ConstantLib.locale,                locale));


In my case everything used to work fine. Suddenly after 2 days my device did not show any https site or image link.

After some investigation it turns out that My time settings was not up to date on device.

I changed my time settings properly and it worked.