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.ExceptionHelper;
import eu.siacs.conversations.utils.MimeUtils; import eu.siacs.conversations.utils.MimeUtils;
import eu.siacs.conversations.utils.OnPhoneContactsLoadedListener; import eu.siacs.conversations.utils.OnPhoneContactsLoadedListener;
import eu.siacs.conversations.utils.PRNGFixes;
import eu.siacs.conversations.utils.PhoneHelper; import eu.siacs.conversations.utils.PhoneHelper;
import eu.siacs.conversations.utils.QuickLoader; import eu.siacs.conversations.utils.QuickLoader;
import eu.siacs.conversations.utils.ReplacingSerialSingleThreadExecutor; import eu.siacs.conversations.utils.ReplacingSerialSingleThreadExecutor;
@ -947,7 +946,11 @@ public class XmppConnectionService extends Service {
public void onCreate() { public void onCreate() {
OmemoSetting.load(this); OmemoSetting.load(this);
ExceptionHelper.init(getApplicationContext()); ExceptionHelper.init(getApplicationContext());
try {
Security.insertProviderAt(Conscrypt.newProvider(), 1); Security.insertProviderAt(Conscrypt.newProvider(), 1);
} catch (Throwable throwable) {
Log.e(Config.LOGTAG,"unable to initialize security provider", throwable);
}
Resolver.init(this); Resolver.init(this);
this.mRandom = new SecureRandom(); this.mRandom = new SecureRandom();
updateMemorizingTrustmanager(); updateMemorizingTrustmanager();

View file

@ -89,7 +89,11 @@ public class SSLSocketHelper {
} }
public static SSLContext getSSLContext() throws NoSuchAlgorithmException { public static SSLContext getSSLContext() throws NoSuchAlgorithmException {
try {
return SSLContext.getInstance("TLSv1.3"); return SSLContext.getInstance("TLSv1.3");
} catch (NoSuchAlgorithmException e) {
return SSLContext.getInstance("TLSv1.2");
}
} }
public static void log(Account account, SSLSocket socket) { public static void log(Account account, SSLSocket socket) {