cloudant / sync-android

A JSON-based document datastore for Android applications
Apache License 2.0
267 stars 91 forks source link

Force tls1.2 on old android #576

Closed ricellis closed 6 years ago

ricellis commented 6 years ago

Thanks for your hard work, please ensure all items are complete before opening.

What

Added a custom SSLSocketFactory for enabling TLS1.2 on Android API < 20.

How

Android API >= 20 already has TLS1.2 enabled by default. API level 19 has it available but not enabled. On older versions of Android it is possible for users to workaround this, for example by configuring the HttpsUrlConnection.setDefaultSocketFactory or similar. However, we can check the API version and set the socket factory for each HttpConnection automatically so that older versions of Android work without any user required changes.

Testing

Existing tests pass. Manually tested on API 19 emulator against TLS1.2 only Cloudant. CI tests run against API >= 20, so don't regularly check this. We could consider an extra branch of testing using the emulator at API level 19.

Issues

N/A