Skip to content

Commit 6014e90

Browse files
use conscrypt
Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
1 parent 4688995 commit 6014e90

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
@@ -303,6 +303,7 @@ dependencies {
303303
annotationProcessor "org.projectlombok:lombok:1.18.8"
304304

305305
ktlint "com.pinterest:ktlint:0.34.2"
306+
implementation 'org.conscrypt:conscrypt-android:2.2.1'
306307

307308
// dependencies for local unit tests
308309
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
@@ -79,14 +79,21 @@
7979
import com.owncloud.android.utils.ReceiversHelper;
8080
import com.owncloud.android.utils.SecurityUtils;
8181

82+
import org.conscrypt.Conscrypt;
83+
8284
import java.lang.reflect.Method;
85+
import java.security.NoSuchAlgorithmException;
86+
import java.security.Security;
8387
import java.util.ArrayList;
88+
import java.util.Arrays;
8489
import java.util.HashMap;
8590
import java.util.List;
8691
import java.util.Map;
8792
import java.util.concurrent.TimeUnit;
8893

8994
import javax.inject.Inject;
95+
import javax.net.ssl.SSLContext;
96+
import javax.net.ssl.SSLEngine;
9097

9198
import androidx.annotation.RequiresApi;
9299
import androidx.annotation.StringRes;
@@ -218,6 +225,8 @@ protected void attachBaseContext(Context base) {
218225
public void onCreate() {
219226
super.onCreate();
220227

228+
insertConscrypt();
229+
221230
SecurityKeyManager securityKeyManager = SecurityKeyManager.getInstance();
222231
SecurityKeyManagerConfig config = new SecurityKeyManagerConfig.Builder()
223232
.setEnableDebugLogging(BuildConfig.DEBUG)
@@ -345,7 +354,25 @@ public static void initContactsBackup(UserAccountManager accountManager) {
345354
ContactsPreferenceActivity.startContactBackupJob(account);
346355
}
347356
}
357+
}
348358

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

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

0 commit comments

Comments
 (0)