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

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

    Allow Android's security Provider to update when starting your app.

    The default Provider before 5.0+ does not disable SSLv3. Provided you have access to Google Play services it is relatively straightforward to patch Android's security Provider from your app.

      private void updateAndroidSecurityProvider(Activity callingActivity) {
        try {
            ProviderInstaller.installIfNeeded(this);
        } catch (GooglePlayServicesRepairableException e) {
          // Thrown when Google Play Services is not installed, up-to-date, or  enabled
            // Show dialog to allow users to install, update, or otherwise    enable Google Play services.
           GooglePlayServicesUtil.getErrorDialog(e.getConnectionStatusCode(), callingActivity, 0);
        } catch (GooglePlayServicesNotAvailableException e) {
            Log.e("SecurityException", "Google Play Services not available.");
        }
    }
    

    Source: Patching the Security Provider with ProviderInstaller Provider

    0 讨论(0)
提交回复
热议问题