Search in sources :

Example 1 with XmppDomainVerifier

use of eu.siacs.conversations.crypto.XmppDomainVerifier in project Conversations by siacs.

the class XmppConnection method getTlsFactoryVerifier.

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()) {
        keyManager = new KeyManager[] { new MyKeyManager() };
    } else {
        keyManager = null;
    }
    String domain = account.getJid().getDomainpart();
    sc.init(keyManager, new X509TrustManager[] { mInteractive ? trustManager.getInteractive(domain) : trustManager.getNonInteractive(domain) }, mXmppConnectionService.getRNG());
    final SSLSocketFactory factory = sc.getSocketFactory();
    final HostnameVerifier verifier;
    if (mInteractive) {
        verifier = trustManager.wrapHostnameVerifier(new XmppDomainVerifier());
    } else {
        verifier = trustManager.wrapHostnameVerifierNonInteractive(new XmppDomainVerifier());
    }
    return new TlsFactoryVerifier(factory, verifier);
}
Also used : MemorizingTrustManager(de.duenndns.ssl.MemorizingTrustManager) XmppDomainVerifier(eu.siacs.conversations.crypto.XmppDomainVerifier) SSLContext(javax.net.ssl.SSLContext) SSLSocketFactory(javax.net.ssl.SSLSocketFactory) X509KeyManager(javax.net.ssl.X509KeyManager) KeyManager(javax.net.ssl.KeyManager) HostnameVerifier(javax.net.ssl.HostnameVerifier)

Aggregations

MemorizingTrustManager (de.duenndns.ssl.MemorizingTrustManager)1 XmppDomainVerifier (eu.siacs.conversations.crypto.XmppDomainVerifier)1 HostnameVerifier (javax.net.ssl.HostnameVerifier)1 KeyManager (javax.net.ssl.KeyManager)1 SSLContext (javax.net.ssl.SSLContext)1 SSLSocketFactory (javax.net.ssl.SSLSocketFactory)1 X509KeyManager (javax.net.ssl.X509KeyManager)1