Search in sources :

Example 1 with DomainHostnameVerifier

use of de.pixart.messenger.crypto.DomainHostnameVerifier in project Pix-Art-Messenger by kriztan.

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 DomainHostnameVerifier verifier = trustManager.wrapHostnameVerifier(new XmppDomainVerifier(), mInteractive);
    return new TlsFactoryVerifier(factory, verifier);
}
Also used : MemorizingTrustManager(de.pixart.messenger.services.MemorizingTrustManager) XmppDomainVerifier(de.pixart.messenger.crypto.XmppDomainVerifier) DomainHostnameVerifier(de.pixart.messenger.crypto.DomainHostnameVerifier) SSLContext(javax.net.ssl.SSLContext) SSLSocketFactory(javax.net.ssl.SSLSocketFactory) X509KeyManager(javax.net.ssl.X509KeyManager) KeyManager(javax.net.ssl.KeyManager)

Aggregations

DomainHostnameVerifier (de.pixart.messenger.crypto.DomainHostnameVerifier)1 XmppDomainVerifier (de.pixart.messenger.crypto.XmppDomainVerifier)1 MemorizingTrustManager (de.pixart.messenger.services.MemorizingTrustManager)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