Hello !
I'm using Android SDK 1.5r3, and I could not find a way to get rid of
either SSLException nor NoSuchAlgorithmException when trying to access
an https ressource.
Of course, I've been searching the internet and the Android
documentation, so far I'm using this code :
public static void disableSSL() {

                try {
//setting a custom hostname verifier (implementing HostNameVerifier;
verify() returns true)
HttpsURLConnection
                                        .setDefaultHostnameVerifier(new 
MyHostNameVerifier());
                        // New X509TrustManager (our manager); implementing
X509TrustManager
                        X509TrustManager x509tm = new MyX509TrustManager();
                        // Needed by SSLContext :
                        KeyManager[] keyManager = null;
                        // Set trust manager :
                        TrustManager[] trustManager = { x509tm };
                        // Get the SSLContext
                        SSLContext sslContent = SSLContext.getInstance("TLS");
                        // Initializaton of the SSLContext
                        sslContent.init(keyManager, trustManager,
                                        new java.security.SecureRandom());
                        // Get the SSLSocketFactory of our new SSLContext
                        SSLSocketFactory socketFactory = 
sslContent.getSocketFactory();
                        // Set this new SSLSocketFactory as default
                        
HttpsURLConnection.setDefaultSSLSocketFactory(socketFactory);
                } catch (KeyManagementException exp) {
                        exp.printStackTrace();
                } catch (NoSuchAlgorithmException exp) {
                        exp.printStackTrace();
                }
This code don't fail actually; but when accessing an HTTPS ressource,
I get the SSLException
If I change TLS by anything else, this code will fail with
NoSuchAlgorithmException
I'm stuck : I can't find a way to resolve this problem...
Thanks in advance for your help !
Anthony
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to