I'm trying to import my selfsigned CA in android so I can make HTTPS POST to a web server I selfsigned. Following Google Doc(https://developer.android.com/training/articles/security-config.html#ConfigCustom) I created directory res/raw/mycertificate and added my certificate in it. Created /res/xml directory and added the xml file network_security_config.xml to the manifest. It's in the network_security_config.xml file that I'm having some trouble, because when I create the tag Android Studio get me an error on src telling me "Missing src resource" but I placed the certificate.pem in the directory /res/raw/mycertificate, and the folders raw and mycertificate does exists. How can I make Android Studio take correctly that path folder?
<network-security-config>
<domain-config>
<domain includeSubdomains="true">192.168.1.200</domain>
<trust-anchors>
<certificates src="@raw/my_ca" />
</trust-anchors>
</domain-config>
Omit the file extension for your certificate file in the network config XML file. If your cert is at res/raw/my_cert.pem
, use this XML code:
<network-security-config>
<domain-config>
<domain includeSubdomains="true">192.168.1.200</domain>
<trust-anchors>
<certificates src="@raw/my_cert" />
</trust-anchors>
</domain-config>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With