SSL 证书握手异常中止从 CloudFront 下载 DownloadManager 图像

SSL certificate handshake exception aborts DownloadManager image download from CloudFront

在我的 Android 应用程序中,我正在尝试从亚马逊服务 CloudFront 下载媒体文件(图像、视频)。

示例 link:https://testcdn.grouvi.org/uploads/94498583-94c4-44b8-911e-2e0c6bcc4b27/86e55069-2627-4c96-9cbe-98fc87f2eb1b.jpg

我用这个代码。

Uri uri = Uri.parse(imageUrl);
String mimeType = MimeTypeMap.getFileExtensionFromUrl(messageComponent.getMediaUrl());
final String fname = "newfilename" + "." + mimeType;
DownloadManager downloadManager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
DownloadManager.Request request = new DownloadManager.Request(uri);
request.setDestinationInExternalPublicDir(context.getResources().getString(R.string.tmp_dir_path), fname);
                    request.setVisibleInDownloadsUi(true);
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE);
long downloadID = downloadManager.enqueue(request);

On Nexus 5(Lolipop), Samsung S5(Kitkat) 图片正在下载。但在 Xaiomi(Kitkat), LG L Fino(Kitkat) 上,图像未下载。并且 DownloadManager.COLUMN_TOTAL_SIZE_BYTES 给出负 -1 值

但是当我直接使用亚马逊时link https://s3.amazonaws.com/grouvi_s/uploads/1c8f59f6-d1a9-430f-ab5c-2a89bcfbe14b/47e461a3-efa9-421a-8bc9-9b18053cbbbc.jpg

所有手机都可以下载媒体文件。

编辑 1

我刚刚在日志中找到了问题的可能原因:

W/DownloadManager﹕ Aborting request for download 840: while trying to execute request: javax.net.ssl.SSLHandshakeException: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0x752a9a60: Failure in SSL library, usually a protocol error
    error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure (external/openssl/ssl/s23_clnt.c:741 0x7362ad74:0x00000000)

据我所知,这是某种证书问题。

请查看此 CVE,我认为它可以解决您的问题:http://aws.amazon.com/security/security-bulletins/CVE-2014-3566-advisory/

这意味着默认情况下禁用 SSLv3,因为它不被认为是安全的