For my app, Transdroid, I am connecting to remote servers via HTTP and optionally securely via HTTPS. For these HTTPS connections with the HttpClient I am using a custom SSL socket factory implementation to make sure self-signed certificates are working. Basically, I accept everything and ignore every checking of any certificate.
This has been working fine for some time now, but it no longer work for Android 2.2 FroYo. When trying to connect, it will return an exception:
java.io.IOException: SSL handshake failure: I/O error during system call, Broken pipe
Here is how I initialize the HttpClient:
SchemeRegistry registry = new SchemeRegistry();
registry.register(new Scheme("http", new PlainSocketFactory(), 80));
registry.register(new Scheme("https", (trustAll ? new FakeSocketFactory() : SSLSocketFactory.getSocketFactory()), 443));
client = new DefaultHttpClient(new ThreadSafeClientConnManager(httpParams, registry), httpParams);
I make use of a FakeSocketFactory and FakeTrustManager, of which the source can be found here.
Again, I don't understand why it suddenly stopped work, or even what the error 'Broken pipe' means. I have seen messages on Twitter that Seesmic and Twidroid fail with SSL enabled on FroYo as well, but am unsure if it's related.
Thanks for any directions/help!
question from:
https://stackoverflow.com/questions/2899079/custom-ssl-handling-stopped-working-on-android-2-2-froyo 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…