From 93e08bc215de6e76c213d8ec2d0b6b8efc19cab8 Mon Sep 17 00:00:00 2001 From: "David A. Velasco" Date: Mon, 17 Nov 2014 10:41:35 +0100 Subject: [PATCH] Grant that all supported secure protocol is enabled, but no unsupported protocol is tried to be enabled --- .../network/AdvancedSslSocketFactory.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/com/owncloud/android/lib/common/network/AdvancedSslSocketFactory.java b/src/com/owncloud/android/lib/common/network/AdvancedSslSocketFactory.java index 9a0d5454..99c05e68 100644 --- a/src/com/owncloud/android/lib/common/network/AdvancedSslSocketFactory.java +++ b/src/com/owncloud/android/lib/common/network/AdvancedSslSocketFactory.java @@ -36,6 +36,7 @@ import javax.net.SocketFactory; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLException; import javax.net.ssl.SSLHandshakeException; +import javax.net.ssl.SSLParameters; import javax.net.ssl.SSLPeerUnverifiedException; import javax.net.ssl.SSLSession; import javax.net.ssl.SSLSocket; @@ -320,9 +321,22 @@ public class AdvancedSslSocketFactory implements SecureProtocolSocketFactory { } } - + /** + * Grants that all protocols supported by the Security Provider in mSslContext are enabled in socket. + * + * Grants also that no unsupported protocol is tried to be enabled. That would trigger an exception, breaking + * the connection process although some protocols are supported. + * + * This is not cosmetic: not all the supported protocols are enabled by default. Too see an overview of + * supported and enabled protocols in the stock Security Provider in Android see the tables in + * http://developer.android.com/reference/javax/net/ssl/SSLSocket.html. + * + * @param socket + */ private void enableSecureProtocols(Socket socket) { - ((SSLSocket) socket).setEnabledProtocols(new String[]{"TLSv1", "TLSv1.1", "TLSv1.2"}); + SSLParameters params = mSslContext.getSupportedSSLParameters(); + String [] supportedProtocols = params.getProtocols(); + ((SSLSocket) socket).setEnabledProtocols(supportedProtocols); } }