From 934ee82bc6e9608055de97a792f8de5a5f3e74e5 Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Sat, 20 Oct 2018 21:22:10 +0200 Subject: catch exception if Conscrypt could not be initialized and use tls 1.2 --- .../java/de/pixart/messenger/services/XmppConnectionService.java | 6 +++++- src/main/java/de/pixart/messenger/utils/SSLSocketHelper.java | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'src/main/java/de/pixart/messenger') diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java index 289823f79..df871dd83 100644 --- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java +++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java @@ -1091,7 +1091,11 @@ public class XmppConnectionService extends Service { public void onCreate() { OmemoSetting.load(this); ExceptionHelper.init(getApplicationContext()); - Security.insertProviderAt(Conscrypt.newProvider(), 1); + try { + Security.insertProviderAt(Conscrypt.newProvider(), 1); + } catch (Throwable throwable) { + Log.e(Config.LOGTAG, "unable to initialize security provider", throwable); + } Resolver.init(this); this.mRandom = new SecureRandom(); updateMemorizingTrustmanager(); diff --git a/src/main/java/de/pixart/messenger/utils/SSLSocketHelper.java b/src/main/java/de/pixart/messenger/utils/SSLSocketHelper.java index 5a1e97551..ce8aa009f 100644 --- a/src/main/java/de/pixart/messenger/utils/SSLSocketHelper.java +++ b/src/main/java/de/pixart/messenger/utils/SSLSocketHelper.java @@ -90,7 +90,11 @@ public class SSLSocketHelper { } public static SSLContext getSSLContext() throws NoSuchAlgorithmException { - return SSLContext.getInstance("TLSv1.3"); + try { + return SSLContext.getInstance("TLSv1.3"); + } catch (NoSuchAlgorithmException e) { + return SSLContext.getInstance("TLSv1.2"); + } } public static void log(Account account, SSLSocket socket) { -- cgit v1.2.3