找不到用于证书路径的Android DownloadManager信任锚

时间:2018-07-25 18:16:18

标签: android download anchor trust

我搜索了很多帖子,但是找不到可以找到任何解决方案或问题答案的地方。 如何从安装了中间证书的站点下载文件? 使用DownloadManager时,出现错误“ java.security.cert.CertPathValidatorException:找不到证书路径的信任锚”。尝试下载文件时。我看到过一些帖子,我应该在此帖子https://developer.android.com/training/articles/security-ssl#java中使用类似的内容 但是我真的不知道该如何为downloadmanager设置SslSocketFactory,以便他可以使用它来下载文件。

1 个答案:

答案 0 :(得分:1)

好的,我找到了解决方案。 只需添加到您的清单

并使用以下代码行转到res-> xml->新文件network_security_config

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <domain-config>
        <domain includeSubdomains="true">example.pl</domain>
    <trust-anchors>
        <certificates src="@raw/path_to_cert"/>
    </trust-anchors>
</domain-config>
</network-security-config>