catch exception if Conscrypt could not be initialized and use tls 1.2

This commit is contained in:
Daniel Gultsch 2018-10-06 19:33:38 +02:00
parent d02b1237f7
commit 521bb7846c
2 changed files with 10 additions and 3 deletions

View file

@ -116,7 +116,6 @@ import eu.siacs.conversations.utils.CryptoHelper;
import eu.siacs.conversations.utils.ExceptionHelper;
import eu.siacs.conversations.utils.MimeUtils;
import eu.siacs.conversations.utils.OnPhoneContactsLoadedListener;
import eu.siacs.conversations.utils.PRNGFixes;
import eu.siacs.conversations.utils.PhoneHelper;
import eu.siacs.conversations.utils.QuickLoader;
import eu.siacs.conversations.utils.ReplacingSerialSingleThreadExecutor;
@ -947,7 +946,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();

View file

@ -89,7 +89,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) {