{"id":7739,"date":"2015-10-19T01:17:25","date_gmt":"2015-10-19T01:17:25","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2015\/10\/19\/okhttp-retrofit-libssl-crash-in-two-way-ssl-authentication-open-source-projects-square-okhttp\/"},"modified":"2015-10-19T01:17:25","modified_gmt":"2015-10-19T01:17:25","slug":"okhttp-retrofit-libssl-crash-in-two-way-ssl-authentication-open-source-projects-square-okhttp","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2015\/10\/19\/okhttp-retrofit-libssl-crash-in-two-way-ssl-authentication-open-source-projects-square-okhttp\/","title":{"rendered":"OkHttp + Retrofit libssl crash in two way SSL authentication-open source projects square\/okhttp"},"content":{"rendered":"<p>OkHttp: 2.0.0-RC1, Retrofit:1.5.1.<\/p>\n<p>I&#8217;m creating okHttp client as mentioned here: NoSuchMethodError if i am using okhttp 2.0 and the latest retrofit? and setting my own <code>SSLScoketFactory<\/code>, and initializing <code>SSLContext<\/code> like this<\/p>\n<pre><code>KeyStore keyStore = App.getInstance().getKeyStoreUtil().getKeyStore();\nKeyStore trustStore = App.getInstance().getKeyStoreUtil().getTrustStore();\n\nTrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());\ntmf.init(trustStore);\n\nKeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());\nkmf.init(keyStore, AppConfig.KEYSTORE_PASSWORD);\n\n\nfinal X509KeyManager origKm = (X509KeyManager) kmf.getKeyManagers()[0];\n\/\/it's standard X509KeyManager, I've put some logging there\nX509KeyManager km = new MyKeyManager(origKm);\n\nSSLContext sslCtx = SSLContext.getInstance(\"TLS\");\nsslCtx.init(new KeyManager[]{km}, tmf.getTrustManagers(), null);\nclient.setSslSocketFactory(sslCtx.getSocketFactory());\nclient.setHostnameVerifier(org.apache.http.conn.ssl.SSLSocketFactory.STRICT_HOSTNAME_VERIFIER);\n<\/code><\/pre>\n<p>When i try to estabilish two way auth SSL connection, every time app crashes with following log:<\/p>\n<pre><code>06-02 17:42:01.215  25176-25542\/pl.oneapp.sugarloaf A\/libc\ufe55 Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 25542 (IntentService[P)\n    06-02 17:42:01.236      253-253\/? I\/DEBUG\ufe55 debuggerd: 2014-06-02 17:42:01\n    06-02 17:42:01.236      253-253\/? I\/DEBUG\ufe55 *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***\n    06-02 17:42:01.236      253-253\/? I\/DEBUG\ufe55 Build fingerprint: 'tmo_de\/ville\/ville:4.1.1\/JRO03C\/148618.10:user\/release-keys'\n    06-02 17:42:01.236      253-253\/? I\/DEBUG\ufe55 pid: 25176, tid: 25542, name: IntentService[P  &gt;&gt;&gt; pl.oneapp.sugarloaf<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>OkHttp: 2.0.0-RC1, Retrofit:1.5.1. I&#8217;m creating okHttp client as mentioned here: NoSuchMethodError if i am using okhttp 2.0 and the latest retrofit? and setting my own SSLScoketFactory, and initializing SSLContext like this KeyStore keyStore = App.getInstance().getKeyStoreUtil().getKeyStore(); KeyStore trustStore = App.getInstance().getKeyStoreUtil().getTrustStore(); TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); tmf.init(trustStore); KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); kmf.init(keyStore, AppConfig.KEYSTORE_PASSWORD); final X509KeyManager origKm = (X509KeyManager) [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-7739","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7739","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=7739"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7739\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=7739"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=7739"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=7739"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}