Demo of how to configure custom trust anchors with network security configuration.
Demo includes 3 commits,
The self signed certificate used is from https://self-signed.badssl.com/
To get the certificate to use in step 3:
> openssl s_client -connect self-signed.badssl.com:443 -showcerts
Documentation of implementation can be found here:
Android - Network security configuration
Implementation includes:
-
Store the certificate in ./android/app/src/main/res/raw/<trusted_cert>
-
Create an xml file in ./android/app/src/main/res/xml/network_security_config.xml with content:
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true">
<trust-anchors>
<certificates src="@raw/<trusted_cert>" />
</trust-anchors>
</base-config>
</network-security-config>
- Add network config to AndroidManifest file in root of Android platform
<application
...
android:networkSecurityConfig="@xml/network_security_config"
...
>
- devzeze -GitHub
This project is licensed under the MIT License - see the LICENSE file for details