create new instances of key manager every time it's used

This commit is contained in:
Daniel Gultsch 2016-10-07 10:04:36 +02:00
parent 187825d6c6
commit 26e33de79a

View file

@ -136,7 +136,7 @@ public class XmppConnection implements Runnable {
private SaslMechanism saslMechanism; private SaslMechanism saslMechanism;
private X509KeyManager mKeyManager = new X509KeyManager() { private class MyKeyManager implements X509KeyManager {
@Override @Override
public String chooseClientAlias(String[] strings, Principal[] principals, Socket socket) { public String chooseClientAlias(String[] strings, Principal[] principals, Socket socket) {
return account.getPrivateKeyAlias(); return account.getPrivateKeyAlias();
@ -149,9 +149,11 @@ public class XmppConnection implements Runnable {
@Override @Override
public X509Certificate[] getCertificateChain(String alias) { public X509Certificate[] getCertificateChain(String alias) {
Log.d(Config.LOGTAG,"getting certificate chain");
try { try {
return KeyChain.getCertificateChain(mXmppConnectionService, alias); return KeyChain.getCertificateChain(mXmppConnectionService, alias);
} catch (Exception e) { } catch (Exception e) {
Log.d(Config.LOGTAG,e.getMessage());
return new X509Certificate[0]; return new X509Certificate[0];
} }
} }
@ -174,7 +176,8 @@ public class XmppConnection implements Runnable {
return null; return null;
} }
} }
}; }
private Identity mServerIdentity = Identity.UNKNOWN; private Identity mServerIdentity = Identity.UNKNOWN;
public final OnIqPacketReceived registrationResponseListener = new OnIqPacketReceived() { public final OnIqPacketReceived registrationResponseListener = new OnIqPacketReceived() {
@ -458,7 +461,7 @@ public class XmppConnection implements Runnable {
MemorizingTrustManager trustManager = this.mXmppConnectionService.getMemorizingTrustManager(); MemorizingTrustManager trustManager = this.mXmppConnectionService.getMemorizingTrustManager();
KeyManager[] keyManager; KeyManager[] keyManager;
if (account.getPrivateKeyAlias() != null && account.getPassword().isEmpty()) { if (account.getPrivateKeyAlias() != null && account.getPassword().isEmpty()) {
keyManager = new KeyManager[]{mKeyManager}; keyManager = new KeyManager[]{new MyKeyManager()};
} else { } else {
keyManager = null; keyManager = null;
} }