|
|
@ -88,14 +88,27 @@ class OkHttpUtils { |
|
|
|
if (Build.VERSION.SDK_INT != Build.VERSION_CODES.N) { |
|
|
|
if (Build.VERSION.SDK_INT != Build.VERSION_CODES.N) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
SSLContext sslContext; |
|
|
|
SSLSocketFactory socketFactory; |
|
|
|
try { |
|
|
|
try { |
|
|
|
sslContext = SSLContext.getInstance("TLS"); |
|
|
|
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance( |
|
|
|
} catch (NoSuchAlgorithmException e) { |
|
|
|
TrustManagerFactory.getDefaultAlgorithm()); |
|
|
|
Log.e(TAG, "Failed obtaining TLS Context."); |
|
|
|
trustManagerFactory.init((KeyStore) null); |
|
|
|
|
|
|
|
TrustManager[] trustManagers = trustManagerFactory.getTrustManagers(); |
|
|
|
|
|
|
|
if (trustManagers.length != 1 || !(trustManagers[0] instanceof X509TrustManager)) { |
|
|
|
|
|
|
|
throw new IllegalStateException("Unexpected default trust managers:" |
|
|
|
|
|
|
|
+ Arrays.toString(trustManagers)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
X509TrustManager trustManager = (X509TrustManager) trustManagers[0]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SSLContext sslContext = SSLContext.getInstance("TLS"); |
|
|
|
|
|
|
|
sslContext.init(null, new TrustManager[] { trustManager }, null); |
|
|
|
|
|
|
|
socketFactory = sslContext.getSocketFactory(); |
|
|
|
|
|
|
|
} catch (NoSuchAlgorithmException|KeyStoreException|KeyManagementException e) { |
|
|
|
|
|
|
|
Log.e(TAG, "Failed obtaining the SSL socket factory."); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
String[] cipherSuites = sslContext.getSocketFactory().getDefaultCipherSuites(); |
|
|
|
String[] cipherSuites = socketFactory.getDefaultCipherSuites(); |
|
|
|
ArrayList<String> allowedList = new ArrayList<>(); |
|
|
|
ArrayList<String> allowedList = new ArrayList<>(); |
|
|
|
for (String suite : cipherSuites) { |
|
|
|
for (String suite : cipherSuites) { |
|
|
|
if (!suite.contains("ECDH")) { |
|
|
|
if (!suite.contains("ECDH")) { |
|
|
|