简体   繁体   English

Glide 从 URl 加载图像

[英]Glide load an image from an URl

I'm trying to use Glide to load an image from an Url:我正在尝试使用 Glide 从 Url 加载图像:

Glide.with(getContext()).load(urlImage).error(R.drawable.ic_profile_default).into(imgUser);

This is the error I get:这是我得到的错误:

W/Glide: Load failed for https:www.cerberusenlinea.com/images/profile/16/13/HOLCIM.jpeg with size [204x204]
    class com.bumptech.glide.load.engine.GlideException: Failed to load resource
    There was 1 cause:
    javax.net.ssl.SSLHandshakeException(java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.)
     call GlideException#logRootCauses(String) for more detail

The problem is that you are trying to take the image from a not secure website, so glide blocks you.问题是你正试图从一个不安全的网站获取图像,所以 glide 会阻止你。 To solve this issue you can create a custom trust manager but is very dangerous because you get exposed to man in the middle attack.要解决此问题,您可以创建一个自定义信任管理器,但这非常危险,因为您会受到中间人攻击。 If you want to follow this route i suggest you to read this Trust Anchor not found for Android SSL Connection如果您想遵循这条路线,我建议您阅读此Trust Anchor not found for Android SSL Connection

Another work around solution, that i suggest could be download the image and host it on your server or on a free service (you can found a lot of them) like https://imgur.com/upload or everyone else另一种解决方案,我建议可以下载图像并将其托管在您的服务器或免费服务(您可以找到很多),例如https://imgur.com/upload或其他人

The HTTPS configuration for the site www.cerberusenlinea.com has chain issues.站点 www.cerberusenlinea.com 的 HTTPS 配置存在链问题。

You can verify it in the Qualys Free Scanner: https://www.ssllabs.com/ssltest/analyze.html?d=www.cerberusenlinea.com您可以在 Qualys 免费扫描仪中验证它: https://www.ssllabs.com/ssltest/analyze.html?d=www.cerberusenlinea.com

结果质量扫描仪

Android requires the full certificate chain in order to consume the content. Android 需要完整的证书链才能使用内容。

The official documentation says: 官方文档说:

Most public CAs don't sign server certificates directly.大多数公共 CA 不直接签署服务器证书。 Instead, they use their main CA certificate, referred to as the root CA, to sign intermediate CAs.相反,他们使用他们的主 CA 证书(称为根 CA)来签署中间 CA。 They do this so the root CA can be stored offline to reduce risk of compromise.他们这样做是为了让根 CA 可以离线存储,以降低泄露风险。 However, operating systems like Android typically trust only root CAs directly, which leaves a short gap of trust between the server certificate—signed by the intermediate CA—and the certificate verifier, which knows the root CA.然而,像 Android 这样的操作系统通常只直接信任根 CA,这在服务器证书(由中间 CA 签名)和知道根 CA 的证书验证者之间留下了短暂的信任差距。 To solve this, the server doesn't send the client only it's certificate during the SSL handshake, but a chain of certificates from the server CA through any intermediates necessary to reach a trusted root CA.为了解决这个问题,在 SSL 握手期间,服务器不会仅向客户端发送它的证书,而是通过任何必要的中间人从服务器 CA 发送证书链以到达受信任的根 CA。

The documentation mention some alternatives in order to address the problem from the application side.该文档提到了一些替代方案,以便从应用程序方面解决问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM