Custom SSL handling stopped working on Android 2.2 FroYo
Here is the answer, with many, many thanks to a helpful Seesmic developer willing to share the fix:
In the custom socket factory, the socket creation (with createSocket
) has apparently been changed specifically for the SSLSocketFactory
implementation. So the old:
@Override public Socket createSocket(Socket socket, String host, int port, boolean autoClose) throws IOException, UnknownHostException { return getSSLContext().getSocketFactory().createSocket(); }
Needs to be changed to:
@Override public Socket createSocket(Socket socket, String host, int port, boolean autoClose) throws IOException, UnknownHostException { return getSSLContext().getSocketFactory().createSocket(socket, host, port, autoClose); }
And then it worked again for me!
UPDATE: As this is still a popular answer, let me update my link to working code. This SSl-enabled socket factory that support modern protocols (TLS 1.1+), SNI and optionally allows to accept all certificates (insecure, ignores all SSL certificates) or a self-signed certificates (by SHA-1 hash).
More Info on this problem http://code.google.com/p/android/issues/detail?id=10472 This fixed the SSL issue we had for HTC Desire when we updated to Android 2.2