mirror of
https://github.com/MaintainTeam/LastPipeBender.git
synced 2025-03-03 06:48:20 +03:00
Use TLSSocketFactoryCompat for Picasso to enable TLSv1.1/1.2 on <=KitKat devices
This commit is contained in:
parent
d1d97a79f0
commit
5c7afbf4d4
2 changed files with 5 additions and 2 deletions
|
@ -35,8 +35,9 @@ public final class OkHttpTlsHelper {
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @param builder The HTTPClient Builder on which TLS is enabled on (will be modified in-place)
|
* @param builder The HTTPClient Builder on which TLS is enabled on (will be modified in-place)
|
||||||
|
* @return the same builder that was supplied. So the method can be chained.
|
||||||
*/
|
*/
|
||||||
public static void enableModernTLS(final OkHttpClient.Builder builder) {
|
public static OkHttpClient.Builder enableModernTLS(final OkHttpClient.Builder builder) {
|
||||||
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
|
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
|
||||||
try {
|
try {
|
||||||
// get the default TrustManager
|
// get the default TrustManager
|
||||||
|
@ -77,5 +78,7 @@ public final class OkHttpTlsHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return builder;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ public final class PicassoHelper {
|
||||||
|
|
||||||
public static void init(final Context context) {
|
public static void init(final Context context) {
|
||||||
picassoCache = new LruCache(10 * 1024 * 1024);
|
picassoCache = new LruCache(10 * 1024 * 1024);
|
||||||
picassoDownloaderClient = new OkHttpClient.Builder()
|
picassoDownloaderClient = OkHttpTlsHelper.enableModernTLS(new OkHttpClient.Builder())
|
||||||
.cache(new okhttp3.Cache(new File(context.getExternalCacheDir(), "picasso"),
|
.cache(new okhttp3.Cache(new File(context.getExternalCacheDir(), "picasso"),
|
||||||
50 * 1024 * 1024))
|
50 * 1024 * 1024))
|
||||||
// this should already be the default timeout in OkHttp3, but just to be sure...
|
// this should already be the default timeout in OkHttp3, but just to be sure...
|
||||||
|
|
Loading…
Add table
Reference in a new issue