Updating OpenSSL in Android Stuido



  • Problem: Google refuses to publish the annex Google.Play♪ Reason: The vulnerabilities were fixed in OpenSSL versions beginning with 1.0.1h, 1.0.0m, and 0.9.8za

    Used Android Studio 1.5Windows 7♪ All packages are updated to the latest versions.

    Tell me how to update. OpenSSL? Thank you so much for your help!

    Annex code:

    import java.io.BufferedReader;
    import java.io.DataOutputStream;
    import java.io.InputStreamReader;
    import java.net.URL;
    import java.security.SecureRandom;
    import java.security.cert.CertificateException;
    import java.security.cert.X509Certificate;
    

    import javax.net.ssl.HostnameVerifier;
    import javax.net.ssl.HttpsURLConnection;
    import javax.net.ssl.SSLContext;
    import javax.net.ssl.SSLSession;
    import javax.net.ssl.TrustManager;
    import javax.net.ssl.X509TrustManager;

    public class DBAction {
    DBAction() {
    }
    public static String getData(String id, String passkey, String command, String param){
    String response = "";
    try {
    String q = "https://myserver.com";
    HostnameVerifier TRUST_ALL_CERTIFICATES = new HostnameVerifier()
    {
    public boolean verify(String hostname, SSLSession session)
    {
    return true;
    }
    };
    SSLContext Cur_SSL_Context = null;
    try
    {
    Cur_SSL_Context = SSLContext.getInstance("TLS");
    Cur_SSL_Context.init(null, new TrustManager[] { new X509_Trust_Manager() }, new SecureRandom());
    }
    catch (Exception e)
    {
    e.printStackTrace();
    }
    HttpsURLConnection.setDefaultHostnameVerifier(TRUST_ALL_CERTIFICATES);
    HttpsURLConnection.setDefaultSSLSocketFactory(Cur_SSL_Context.getSocketFactory());
    URL url = new URL(q);
    HttpsURLConnection httpsURLConnection= (HttpsURLConnection) url.openConnection();
    httpsURLConnection.setRequestMethod("POST");
    httpsURLConnection.setDoOutput(true);

            String urlParameters =DBHelper.PARAM_POST_ID+"="+id+ "&" + DBHelper.PARAM_POST_PASSKEY + "="+passkey;
            if (param != null)
            {
                urlParameters += "&";
                urlParameters += DBHelper.PARAM_POST_PARAM;
                urlParameters += "=";
                urlParameters = param;
            }
    
            DataOutputStream wr = new DataOutputStream(httpsURLConnection.getOutputStream());
            wr.writeBytes(urlParameters);
            wr.flush();
            wr.close();
            BufferedReader in = new BufferedReader(
                    new InputStreamReader(httpsURLConnection.getInputStream()));
            String inputLine;
            StringBuffer stringBuffer = new StringBuffer();
    
            while ((inputLine = in.readLine()) != null) {
                stringBuffer.append(inputLine);
            }
            in.close();
            int responseCode = httpsURLConnection.getResponseCode();
            response = stringBuffer.toString();
        }
        catch (Exception e) {
            System.out.print("Exception = " + e);
    
        }
        return response;
    }
    
    private static class X509_Trust_Manager implements X509TrustManager
    {
        @Override
        public void checkClientTrusted(X509Certificate[] chain, String authType)
                throws CertificateException {}
        @Override
        public void checkServerTrusted(X509Certificate[] chain, String authType)
                throws CertificateException {}
        @Override
        public X509Certificate[] getAcceptedIssuers()
        {
            return null;
        }
    };
    

    }

    UPDrecommended by Guglom
    '$ unzip -p YourApp.apk ой strings ой grep "OpenSSL" gives an empty result.

    UPD2: libs - empty

    dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:recyclerview-v7:23.1.1'
    }



  • If necessary, there are two ways to update the building libraries:

    1. Find ready. .so Libraries and include them in the project as NDK dependency; then clearly in the code call System.loadLibrary("yourlib"); (Don't forget the exceptions that this function can throw away)
    2. Treat the library references, collect these libraries separately, then move to p.1

    WARNING:

    We need to remember that there's a parameter like ABI (sighs) https://developer.android.com/ndk/guides/abis.html ) Controls him when gradle parameter assembly abiFilter♪ For alls of the architecture, the library should be assembled, which should lie in the file.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2