我最近更新了asmack jar。現在我收到如下錯誤:「CertPathValidatorException:找不到證書路徑的信任錨。」 (a)Smack 4.0.0
07-18 12:49:29.523:W/XMPPConnection(6817):javax.net.ssl.SSLHandshakeException:java.security.cert.CertPathValidatorException:證書路徑的信任錨未找到。
當我試圖連接。早些時候一切正常(舊版本)。
我最近更新了asmack jar。現在我收到如下錯誤:「CertPathValidatorException:找不到證書路徑的信任錨。」 (a)Smack 4.0.0
07-18 12:49:29.523:W/XMPPConnection(6817):javax.net.ssl.SSLHandshakeException:java.security.cert.CertPathValidatorException:證書路徑的信任錨未找到。
當我試圖連接。早些時候一切正常(舊版本)。
SSL配置不正確。那些信任錨定錯誤通常意味着無法找到信任存儲。檢查你的配置,確保你實際上指向了信任存儲並且它已經到位。
是,與舊版本asmack的(直到aSmack-0.8.10),下面的代碼沒有任何錯誤是工作的罰款,如果你喜歡寫東西下面,
ConnectionConfiguration connConfig =新ConnectionConfiguration( 「HOST_NAME」 ,5222); connConfig.setSecurityMode(SecurityMode.enabled);
但隨着asmack的新版本(aSmack-4.0.4)此錯誤是將保持持續,如果您使用connConfig.setSecurityMode(SecurityMode.enabled);
正如@cOcO在此提及的SSL配置不正確。對此,您可以使用MemorizingTrustManager。
它是一個開源的庫,在eclipse中下載並導入爲android項目,並將android項目添加爲libraryProject。
加入這個庫下面後行添加到您的AndroidManifest.xml
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity android:name="de.duenndns.ssl.MemorizingActivity"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
</application>
現在添加下面的代碼在您的XMPP服務
try {
SSLContext sc = SSLContext.getInstance("TLS");
sc.init(null, MemorizingTrustManager.getInstanceList(this.getApplicationContext()), new SecureRandom());
connConfig.setCustomSSLContext(sc);
} catch (NoSuchAlgorithmException e) {
throw new IllegalStateException(e);
} catch (KeyManagementException e) {
throw new IllegalStateException(e);
}
希望上面的代碼將解決您的問題。
編輯:16_10_2014 有關信任管理器的詳細信息,您可以訪問此鏈接https://github.com/Flowdalic/asmack/wiki/Truststore
代理的問題,我猜!嘗試連接到其他網絡,然後嘗試。 –