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