Adding trust anchors to network_security_config.xml file to pin SSL certificate

I am using HTTP from @ionic-native in my ionic 4 project to request a token from a domain, and that domain has an SSL certificate which I need to pin in the network_security_config.xml file of the android platform. So, I have used trust anchors in network_security_config.xml file and when send the request I get this error

status = -1,
error = “Failed to parse XML configuration from network_security_config”

and this is my network_security_config.xml file:

<?xml version="1.0" encoding="utf-8"?> <network-security-config> <domain-config cleartextTrafficPermitted="true"> <domain includeSubdomains="true">localhost</domain> <trust-anchors> <certificates src="www/certificates/cor-YARPVSVCA-CA-1.cer" /> </trust-anchors> </domain-config> </network-security-config>

My ionic info:


Ionic CLI : 5.0.3
Ionic Framework : @ionic/angular 4.5.0
@angular-devkit/build-angular : 0.13.9
@angular-devkit/schematics : 7.3.9
@angular/cli : 7.3.9
@ionic/angular-toolkit : 1.5.1


Cordova CLI : 9.0.0 (cordova-lib@9.0.1)
Cordova Platforms : android 8.0.0
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 4.1.1, (and 12 other plugins)


cordova-res : 0.4.0
native-run : 0.2.7


Android SDK Tools : 26.1.1 (C:\Android)
NodeJS : v10.7.0 (C:\Program Files\nodejs\node.exe)
npm : 6.2.0
OS : Windows 10

Has anyone tried this, if so am I placing the certificates in the right path? Please help.

You can find usefull info at