Skip to content

Commit

Permalink
smackable: use MTM.HostnameVerifier
Browse files Browse the repository at this point in the history
  • Loading branch information
ge0rg committed Jul 24, 2014
1 parent 83da93d commit 40f0f4a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/org/yaxim/androidclient/service/SmackableImp.java
Expand Up @@ -6,6 +6,8 @@
import javax.net.ssl.SSLContext;
import javax.net.ssl.X509TrustManager;

import de.duenndns.ssl.MemorizingTrustManager;

import org.jivesoftware.smack.AccountManager;
import org.jivesoftware.smack.ConnectionConfiguration;
import org.jivesoftware.smack.ConnectionListener;
Expand Down Expand Up @@ -197,9 +199,12 @@ private synchronized void initXMPPConnection() {
// register MemorizingTrustManager for HTTPS
try {
SSLContext sc = SSLContext.getInstance("TLS");
sc.init(null, new X509TrustManager[] { YaximApplication.getApp(mService).mMTM },
MemorizingTrustManager mtm = YaximApplication.getApp(mService).mMTM;
sc.init(null, new X509TrustManager[] { mtm },
new java.security.SecureRandom());
this.mXMPPConfig.setCustomSSLContext(sc);
this.mXMPPConfig.setHostnameVerifier(mtm.wrapHostnameVerifier(
new org.apache.http.conn.ssl.StrictHostnameVerifier()));
} catch (java.security.GeneralSecurityException e) {
debugLog("initialize MemorizingTrustManager: " + e);
}
Expand Down

0 comments on commit 40f0f4a

Please sign in to comment.