Skip to content

Commit 527c5db

Browse files
Use conscrypt (#4314)
Use conscrypt
2 parents 5373660 + 6014e90 commit 527c5db

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ dependencies {
307307
annotationProcessor "org.projectlombok:lombok:1.18.8"
308308

309309
ktlint "com.pinterest:ktlint:0.34.2"
310+
implementation 'org.conscrypt:conscrypt-android:2.2.1'
310311

311312
// dependencies for local unit tests
312313
testImplementation 'junit:junit:4.12'

src/main/java/com/owncloud/android/MainApp.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,21 @@
8080
import com.owncloud.android.utils.ReceiversHelper;
8181
import com.owncloud.android.utils.SecurityUtils;
8282

83+
import org.conscrypt.Conscrypt;
84+
8385
import java.lang.reflect.Method;
86+
import java.security.NoSuchAlgorithmException;
87+
import java.security.Security;
8488
import java.util.ArrayList;
89+
import java.util.Arrays;
8590
import java.util.HashMap;
8691
import java.util.List;
8792
import java.util.Map;
8893
import java.util.concurrent.TimeUnit;
8994

9095
import javax.inject.Inject;
96+
import javax.net.ssl.SSLContext;
97+
import javax.net.ssl.SSLEngine;
9198

9299
import androidx.annotation.RequiresApi;
93100
import androidx.annotation.StringRes;
@@ -224,6 +231,8 @@ protected void attachBaseContext(Context base) {
224231
public void onCreate() {
225232
super.onCreate();
226233

234+
insertConscrypt();
235+
227236
SecurityKeyManager securityKeyManager = SecurityKeyManager.getInstance();
228237
SecurityKeyManagerConfig config = new SecurityKeyManagerConfig.Builder()
229238
.setEnableDebugLogging(BuildConfig.DEBUG)
@@ -350,7 +359,25 @@ public static void initContactsBackup(UserAccountManager accountManager) {
350359
ContactsPreferenceActivity.startContactBackupJob(account);
351360
}
352361
}
362+
}
353363

364+
private void insertConscrypt() {
365+
Security.insertProviderAt(Conscrypt.newProvider(), 1);
366+
367+
try {
368+
Conscrypt.Version version = Conscrypt.version();
369+
Log_OC.i(TAG, "Using Conscrypt/"
370+
+ version.major()
371+
+ "."
372+
+ version.minor()
373+
+ "." + version.patch()
374+
+ " for TLS");
375+
SSLEngine engine = SSLContext.getDefault().createSSLEngine();
376+
Log_OC.i(TAG, "Enabled protocols: " + Arrays.toString(engine.getEnabledProtocols()) + " }");
377+
Log_OC.i(TAG, "Enabled ciphers: " + Arrays.toString(engine.getEnabledCipherSuites()) + " }");
378+
} catch (NoSuchAlgorithmException e) {
379+
Log_OC.e(TAG, e.getMessage());
380+
}
354381
}
355382

356383
@SuppressLint("ApplySharedPref") // commit is done on purpose to write immediately

0 commit comments

Comments
 (0)