aditcodes / socialauth-android

Automatically exported from code.google.com/p/socialauth-android
0 stars 0 forks source link

fix back compatibility issue for android 2.2 and pre #39

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
i found the problem was in ssl in socialauth-core so if we replaced the code in 
HttpUtil 
static {
        SSLContext ctx;
try
{
ctx = SSLContext.getInstance("TLS");
            ctx.init(new KeyManager[0],
                    new TrustManager[] { new DefaultTrustManager() },
                    new SecureRandom());
            SSLContext.setDefault(ctx);
        }
        catch (Exception ex) {

            ex.printStackTrace();
        }
    }
with this code it will work on any android
static {
        SSLContext ctx;
        try {
            if (Build.VERSION.SDK_INT <10)
                {
                ctx = SSLContext.getInstance("TLS");
                ctx.init(null, new TrustManager[] {
                  new X509TrustManager() {
                    public void checkClientTrusted(X509Certificate[] chain, String authType) {}
                    public void checkServerTrusted(X509Certificate[] chain, String authType) {}
                    public X509Certificate[] getAcceptedIssuers() { return new X509Certificate[]{}; }
                  }
                }, null);
                HttpsURLConnection.setDefaultSSLSocketFactory(ctx.getSocketFactory());
                HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {

                    @Override
                    public boolean verify(String arg0, SSLSession arg1) {
                        // TODO Auto-generated method stub
                        return true;
                    }

                    });
                }else{
            ctx = SSLContext.getInstance("TLS");
            ctx.init(new KeyManager[0],
                    new TrustManager[] { new DefaultTrustManager() },
                    new SecureRandom());
            SSLContext.setDefault(ctx);
                }
        }
        catch (Exception ex) {

            ex.printStackTrace();
        }
    }

Original issue reported on code.google.com by mazzi...@gmail.com on 4 Mar 2013 at 1:10

GoogleCodeExporter commented 9 years ago
Hi , 

We are not looking to support Android SDK 2.2 and pre. The SDK will be 
supported form Android SDK 2.3.3

Original comment by vineet.a...@3pillarglobal.com on 4 Mar 2013 at 1:12

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
thanks for your fast response but can you keep this thread to any  one wants to 
 do it for his own good?

Original comment by mazzi...@gmail.com on 4 Mar 2013 at 1:19

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
i was just want to tell you that socialauth now support android 2.2 so you can 
add it to let other people benefit from it.
http://code.google.com/p/socialauth/issues/detail?id=252

Original comment by mazzi...@gmail.com on 7 Mar 2013 at 12:47

GoogleCodeExporter commented 9 years ago
Thanks mazzica1

We have integrated your fix in latest release. The new version supports SDK 2.1 
and SDK 2.2

Original comment by vineet.a...@3pillarglobal.com on 7 Mar 2013 at 2:23