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

前端 未结 7 1679
小蘑菇
小蘑菇 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:19

    If you have access to the server with a trusted certificate a much better solutionis to correctly configure the SSL because android is more restricted that iOS and desktop browser regarding SSL verification

    This solution does not require any changes in your android app, so it is more clean.

    Here is an example SSL configuration for apache (add it to your VirtualHost definition e.g. /etc/apache2/sites-enabled)

    SSLEngine on
    SSLCertificateFile    YOUR_CERT_PATH
    SSLCACertificateFile  CA_ROOT_CERT_PATH
    SSLCertificateKeyFile KEY_PATH
    

    I had the same error and when I added the CA root certificate, the error gone and android did not complain anymore. Provide the correct paths for these files, restart Apache and test again.

    The file for the CA root certificate can contain both the root and intermediate certificate

    You can test your SSL configuration with this site and make sure that in the result under Certification Paths that the server is sending all the required certificates.

提交回复
热议问题