Whenever this code runs, I get a \'No Peer Certificate\' error.
SSL certificate is valid, bought from Namecheap (PositiveSSL). It has the CA crt before it, and opens
I'm actually trying to diagnose this myself right now, and it appears one thing that may cause this issue is that the server is down or the connection times out.
Make sure you are using HttpsURLConnection
instead of HttpURLConnection
.
I remove all the Scheme Registry staff and the "No peer Certification error" is solved.
ie.
I remove this code from mine
SchemeRegistry schReg = new SchemeRegistry();
schReg.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
schReg.register(new Scheme("https",SSLSocketFactory.getSocketFactory(), 443));
SingleClientConnManager conMgr = new SingleClientConnManager(params,post.getParams());
may be you can try remove those from yours.
I have just recently gone through this problem. It wasn't the chain order that was the problem, but I have had that before.
What was the issue was that the server only accepts TLS1.2 socket connections. android 19 and lower default socket connection is TLS1 SSLSocket Docs
With the help of Enable TLS 1.2 in Android 4.4 I was able to get this to work. The question description worked for me. But please ensure that you do have the answer code in you application
Check your system time.If the time is not current time may cause this error.
If it is not a Server issue, which in most cases that I have seen this issue it is related to either missing intermediate certs or bad a install of the certs.
Try using the Scheme Registry like this:
SchemeRegistry schReg = new SchemeRegistry();
schReg.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
schReg.register(new Scheme("https",SSLSocketFactory.getSocketFactory(), 443));
SingleClientConnManager conMgr = new SingleClientConnManager(params,post.getParams());