问题描述
我想从https:// url下载apk文件。当我第一次尝试下载时,它说
java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
所以我搜索了互联网并添加了network_secuirty_config.xml文件。
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config>
<domain includeSubdomains="true">companyName.in</domain>
<trust-anchors>
<certificates src="@raw/rapid"/>
</trust-anchors>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">phantom.companyName.in</domain>
</domain-config>
</domain-config>
</network-security-config>
现在错误是
Stop requested with status HTTP_DATA_ERROR: Hostname phantom.companyName.in not verified:
我搜索了所有地方,但找不到解决错误的方法。 这是我的下载管理器请求入队代码。
//create download request
DownloadManager.Request request = new DownloadManager.Request(uri);
//allow types of network to download files
request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI | DownloadManager.Request.NETWORK_MOBILE);
request.setMimeType(FileUtils.getMimeType(uri.toString()));
request.setTitle("Download");
request.setDescription("Downloading File...");
request.allowScanningByMediaScanner();
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
request.setDestinationInExternalFilesDir(this,Environment.DIRECTORY_DOWNLOADS,"/" + filename);
//get download service and enqueue file
DownloadManager manager = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
m_downloadID = manager.enqueue(request);
PS:-我为应用程序This is how i send https requests中的常规https请求添加了一个主机名验证程序。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)