Universal-Image-Loader | SSLHandshakeException: Handshake failed(通用图像加载器 |SSLHandshakeException:握手失败)
问题描述
我有一个 ListView,其中包含一些内容(TextViews、ImageView...).我正在使用 Nostra 的 UIL 来加载项目中的图像,但其中一些他们无法加载.当我调用 Log.v(String.valueOf(failReason.getCause());
时,这就是我得到的:
I have a ListView with some content (TextViews, ImageView...) in the items. I'm using UIL by Nostra to load the images in the items but some of them fail to load. This is what do I get, when i call Log.v(String.valueOf(failReason.getCause());
:
11-16 23:52:20.447: V/javax.net.ssl.SSLHandshakeException: Handshake failed(17467): failz
11-16 23:52:20.657: V/NativeCrypto(17467): SSL handshake aborted: ssl=0x15fd758: Failure in SSL library, usually a protocol error
11-16 23:52:20.657: V/NativeCrypto(17467): error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure (external/openssl/ssl/s23_clnt.c:762 0x4c2ed485:0x00000000)
11-16 23:52:21.207: V/NativeCrypto(17467): SSL handshake aborted: ssl=0x1562468: Failure in SSL library, usually a protocol error
11-16 23:52:21.207: V/NativeCrypto(17467): error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure (external/openssl/ssl/s23_clnt.c:762 0x4c2ed485:0x00000000)
你不知道,为什么会出现这个问题或者我该如何解决?
Don't you know, why is there this problem or how can I solve it?
这是一张示例图片,未加载:
This is one example image, which doesn't get loaded:
http://bigparty.cz/photos/headlinefoto/13.jpg
(我可以附加一个带有整个错误的日志 - UIL 自动放入日志的错误)
(I can attach a Log with the whole error - error which UIL automatically puts to Log)
推荐答案
如果我是对的,您必须创建一个证书,对其进行签名并将其包含在您的应用程序中.或更改服务器配置(此处了解更多信息).
If I'm right you have to create a certificate, sign it and include it in your app. Or change the server configuration (further information here).
否则,您可以信任应用中的每次握手.这不是最好的方法,但在实施过程中非常有用.
Otherwise you can trust every handshake within your app. This is not the best approach, but really useful during implementation.
在你的项目中包含这个类
Include this class in your project
public class SSLCertificateHandler {
protected static final String TAG = "NukeSSLCerts";
/**
* Enables https connections
*/
public static void nuke() {
try {
TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() {
public X509Certificate[] getAcceptedIssuers() {
X509Certificate[] myTrustedAnchors = new X509Certificate[0];
return myTrustedAnchors;
}
@Override
public void checkClientTrusted(X509Certificate[] certs, String authType) {
}
@Override
public void checkServerTrusted(X509Certificate[] certs, String authType) {
}
} };
SSLContext sc = SSLContext.getInstance("SSL");
sc.init(null, trustAllCerts, new SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
@Override
public boolean verify(String arg0, SSLSession arg1) {
return true;
}
});
} catch (Exception e) {
}
}
}
扩展你的Application
,并在你的onCreate
中调用'nuke'函数
Extend your Application
, and call the 'nuke' function in your onCreate
public class YOURApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
//...
// trust all SSL -> HTTPS connection
SSLCertificateHandler.nuke();
}
我在 SO 中找到了这段代码,但目前找不到链接....
I found this code in SO, but can't find the link at the moment....
这篇关于通用图像加载器 |SSLHandshakeException:握手失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:通用图像加载器 |SSLHandshakeException:握手失败
基础教程推荐
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01