forked from mirror/monocles_chat
always use private key for TLS connection when one is configured
(cherry picked from commit 36d2ecfcfa9351809655731f57b1249c96f9f91c)
This commit is contained in:
parent
dd2d12d28e
commit
7a8e707df3
3 changed files with 8 additions and 9 deletions
src/main/java/eu/siacs/conversations
|
@ -2502,7 +2502,7 @@ public class XmppConnectionService extends Service {
|
|||
return;
|
||||
}
|
||||
if (findAccountByJid(info.first) == null) {
|
||||
Account account = new Account(info.first, "");
|
||||
final Account account = new Account(info.first, "");
|
||||
account.setPrivateKeyAlias(alias);
|
||||
account.setOption(Account.OPTION_DISABLED, true);
|
||||
account.setDisplayName(info.second);
|
||||
|
@ -2519,7 +2519,6 @@ public class XmppConnectionService extends Service {
|
|||
callback.informUser(R.string.account_already_exists);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
callback.informUser(R.string.unable_to_parse_certificate);
|
||||
}
|
||||
}).start();
|
||||
|
|
|
@ -407,15 +407,15 @@ public class ManageAccountActivity extends XmppActivity implements OnAccountUpda
|
|||
}
|
||||
|
||||
@Override
|
||||
public void alias(String alias) {
|
||||
public void alias(final String alias) {
|
||||
if (alias != null) {
|
||||
xmppConnectionService.createAccountFromKey(alias, this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAccountCreated(Account account) {
|
||||
Intent intent = new Intent(this, EditAccountActivity.class);
|
||||
public void onAccountCreated(final Account account) {
|
||||
final Intent intent = new Intent(this, EditAccountActivity.class);
|
||||
intent.putExtra("jid", account.getJid().asBareJid().toString());
|
||||
intent.putExtra("init", true);
|
||||
startActivity(intent);
|
||||
|
|
|
@ -447,14 +447,14 @@ public class XmppConnection implements Runnable {
|
|||
|
||||
private TlsFactoryVerifier getTlsFactoryVerifier() throws NoSuchAlgorithmException, KeyManagementException, IOException {
|
||||
final SSLContext sc = SSLSocketHelper.getSSLContext();
|
||||
MemorizingTrustManager trustManager = this.mXmppConnectionService.getMemorizingTrustManager();
|
||||
KeyManager[] keyManager;
|
||||
if (account.getPrivateKeyAlias() != null && account.getPassword().isEmpty()) {
|
||||
final MemorizingTrustManager trustManager = this.mXmppConnectionService.getMemorizingTrustManager();
|
||||
final KeyManager[] keyManager;
|
||||
if (account.getPrivateKeyAlias() != null) {
|
||||
keyManager = new KeyManager[]{new MyKeyManager()};
|
||||
} else {
|
||||
keyManager = null;
|
||||
}
|
||||
String domain = account.getJid().getDomain();
|
||||
final String domain = account.getJid().getDomain();
|
||||
sc.init(keyManager, new X509TrustManager[]{mInteractive ? trustManager.getInteractive(domain) : trustManager.getNonInteractive(domain)}, mXmppConnectionService.getRNG());
|
||||
final SSLSocketFactory factory = sc.getSocketFactory();
|
||||
final DomainHostnameVerifier verifier = trustManager.wrapHostnameVerifier(new XmppDomainVerifier(), mInteractive);
|
||||
|
|
Loading…
Add table
Reference in a new issue