通用图像加载器| SSLHandshakeException:握手失败 [英] Universal-Image-Loader | SSLHandshakeException: Handshake failed

查看:182
本文介绍了通用图像加载器| SSLHandshakeException:握手失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在项目中有一些包含一些内容(TextViews,ImageView ...)的ListView。我正在使用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?

这是一个例子mage,没有加载:

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.

在项目中包含此类

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) {
    }
}

}

扩展应用,并在 onCreate <中调用'nuke'函数/ p>

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:握手失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆