Android SSL HttpGet (No peer certificate) error OR (Connection closed by peer) error

前端 未结 7 1644
小蘑菇
小蘑菇 2020-12-02 05:39

I am trying to do a simple HttpGet to read a webpage. I have this working on iOS and working on Android over http, but not https.

The url is an internal network IP a

7条回答
  •  时光取名叫无心
    2020-12-02 06:33

    When searching for this exception, all you get is the advice to implement "allow all certs".

    The javadoc for SSLPeerUnverifiedException states:

    When the peer was not able to identify itself (for example; no certificate, the particular cipher suite being used does not support authentication, or no peer authentication was established during SSL handshaking) this exception is thrown.

    So the error might be that the connection is so flaky/unstable and requests take ridiculous amounts of time. In our mobile app we sometimes experience lot's of connection/Socket-Timeouts in combination with these SSLPeerUnverifiedException. Some requests get through but take 60s+ - the network connection simply sucks beyond all means in these cases.

    Simply brute forcing this with the "allow all certs" is not advisable in such cases - rather implement a proper retry strategy.

提交回复
热议问题