Android SSL - No Peer Certificate

前端 未结 10 699
鱼传尺愫
鱼传尺愫 2020-12-05 03:30

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

相关标签:
10条回答
  • 2020-12-05 03:41

    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.

    0 讨论(0)
  • 2020-12-05 03:44

    Make sure you are using HttpsURLConnection instead of HttpURLConnection.

    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2020-12-05 03:52

    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

    0 讨论(0)
  • 2020-12-05 03:53

    Check your system time.If the time is not current time may cause this error.

    0 讨论(0)
  • 2020-12-05 03:55

    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());
    
    0 讨论(0)
提交回复
热议问题