mirror of
https://github.com/owncloud/android-library.git
synced 2025-07-23 18:06:17 +00:00
Use TLSv1.3 if available
This commit is contained in:
parent
7710db7612
commit
76a808cb0d
@ -71,16 +71,21 @@ public class HttpClient {
|
|||||||
SSLContext sslContext;
|
SSLContext sslContext;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
sslContext = SSLContext.getInstance("TLSv1.2");
|
sslContext = SSLContext.getInstance("TLSv1.3");
|
||||||
} catch (NoSuchAlgorithmException tlsv12Exception) {
|
} catch (NoSuchAlgorithmException tlsv13Exception) {
|
||||||
try {
|
try {
|
||||||
Timber.w("TLSv1.2 is not supported in this device; falling through TLSv1.1");
|
Timber.w("TLSv1.3 is not supported in this device; falling through TLSv1.2");
|
||||||
sslContext = SSLContext.getInstance("TLSv1.1");
|
sslContext = SSLContext.getInstance("TLSv1.2");
|
||||||
} catch (NoSuchAlgorithmException tlsv11Exception) {
|
} catch (NoSuchAlgorithmException tlsv12Exception) {
|
||||||
Timber.w("TLSv1.1 is not supported in this device; falling through TLSv1.0");
|
try {
|
||||||
sslContext = SSLContext.getInstance("TLSv1");
|
Timber.w("TLSv1.2 is not supported in this device; falling through TLSv1.1");
|
||||||
// should be available in any device; see reference of supported protocols in
|
sslContext = SSLContext.getInstance("TLSv1.1");
|
||||||
// http://developer.android.com/reference/javax/net/ssl/SSLSocket.html
|
} catch (NoSuchAlgorithmException tlsv11Exception) {
|
||||||
|
Timber.w("TLSv1.1 is not supported in this device; falling through TLSv1.0");
|
||||||
|
sslContext = SSLContext.getInstance("TLSv1");
|
||||||
|
// should be available in any device; see reference of supported protocols in
|
||||||
|
// http://developer.android.com/reference/javax/net/ssl/SSLSocket.html
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,8 +74,8 @@ public class TLSSocketFactory extends SSLSocketFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Socket enableTLSOnSocket(Socket socket) {
|
private Socket enableTLSOnSocket(Socket socket) {
|
||||||
if(socket != null && (socket instanceof SSLSocket)) {
|
if((socket instanceof SSLSocket)) {
|
||||||
((SSLSocket)socket).setEnabledProtocols(new String[] {"TLSv1.1", "TLSv1.2"});
|
((SSLSocket)socket).setEnabledProtocols(new String[] {"TLSv1.1", "TLSv1.2", "TLSv1.3"});
|
||||||
}
|
}
|
||||||
return socket;
|
return socket;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user