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).
Regarding Froyo Android 2.2
It means you have no preference for where the application is installed; it can be installed in either the sdcard or the main memory, depending on the device's preferences.
Geocoder not working in Android 2.2 and beyond
Found that its an issue with the Emulator, but not with the real devices.
Self-signed SSL acceptance on Android
I have this functionality in exchangeIt, which connects to Microsoft exchange via WebDav. Here's some code to create an HttpClient which will connect to self signed cert's via SSL:
SchemeRegistry schemeRegistry = new SchemeRegistry();
// http scheme
schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
// https scheme
schemeRegistry.register(new Scheme("https", new EasySSLSocketFactory(), 443));
HttpParams params = new BasicHttpParams();
params.setParameter(ConnManagerPNames.MAX_TOTAL_CONNECTIONS, 30);
params.setParameter(ConnManagerPNames.MAX_CONNECTIONS_PER_ROUTE, new ConnPerRouteBean(30));
params.setParameter(HttpProtocolParams.USE_EXPECT_CONTINUE, false);
HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
ClientConnectionManager cm = new ThreadSafeClientConnManager(params, schemeRegistry);
The EasySSLSocketFactory is here, and the EasyX509TrustManager is here.
The code for exchangeIt is open source, and hosted on googlecode here, if you have any issues. I'm not actively working on it anymore, but the code should work.
Note that since Android 2.2 the process has changed a bit, so check this to make the code above work.
Related Topics
Difference Between Android-Support-V7-Appcompat and Android-Support-V4
Low-Latency Audio Playback on Android
What Is the Intent of the Methods Getitem and Getitemid in the Android Class Baseadapter
How to Display Input Errors in Popup
How to Create Custom UI for Android Mediacontroller
How to Programmatically Set the Background Color Gradient on a Custom Title Bar
Hiding the Actionbar on Recyclerview/Listview Onscroll
Jni and Gradle in Android Studio
How to Hide a Button Programmatically
How to Add a Fast-Scroller to the Recyclerview
How to Attach the Android Support Library Source in Eclipse
How to Change Background Color in Android App
How to Limit the Height of Spinner Drop Down View in Android
Getting the Battery Current Values for the Android Phone
Toggle Button Using Two Image on Different State
Android O - Old Start Foreground Service Still Working