I want to download an apk file from https://url . when i first tried downloading , it said
java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
so i searched internet and addd , network_secuirty_config.xml file .
<?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>
Now the error is
Stop requested with status HTTP_DATA_ERROR: Hostname phantom.companyName.in not verified:
i have searched every where but couldn't find a way to resolve the error. This is my download manager request enqueue code.
//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:- I have added an hostname verifier for normal https requests inside the application, This is how i send https requests.