resource raw/my_ca not found
Description
I'm trying to setup a .net maui android platform to allow private CA certificate as described at https://developer.android.com/training/articles/security-config, it ask me to put my CA certificate at
res/raw/my_ca
In my project I do that at MyAppFolder\Platfroms\Android\Resources\raw\my_ca and leave ther my .pem CA certificate, but whene I try to deploy to my android test phone it shows me:
APT2260 resource raw/my_ca (aka com.companyname.paradigman.apps.controln:raw/my_ca) not found. ParadigmaN.Apps.ControlN D:\Proyectos\Proyectos.Net\ParadigmaN!\ParadigmaN\ParadigmaN.Apps.ControlN\Resources\xml\network_security_config.xml 2
I added same file at MyAppFolder\Resources\Raw
Steps to Reproduce
1 Create .net maui application
2 Add folder raw at Platforms\Android\Resources
3 Add folder my_ca at Platforms\Android\Resources\raw
3 Add folder xml at Platforms\Android\Resources
4 Add network_security_config.xml file to folder at step 3 with this content <?xml version="1.0" encoding="utf-8"?> <network-security-config> <domain-config cleartextTrafficPermitted="false"> <trust-anchors> <certificates src="@raw/my_ca"/> </trust-anchors> </domain-config> </network-security-config>
5 Add a .pem file to Platforms\Android\Resources\raw\my_ca
Try to deply to an android device
Link to public reproduction project repository
https://github.com/jupagose/mauibug_trusted_roots
Version with bug
6.0.400
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
Android 12
Did you find any workaround?
NO
Relevant log output
Build started...
1>------ Build started: Project: ParadigmaN.Apps.ControlN, Configuration: Debug Any CPU ------
1>Resources\xml\network_security_config.xml(2): error APT2260: resource raw/my_ca (aka com.companyname.paradigman.apps.controln:raw/my_ca) not found.
1>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\32.0.448\tools\Xamarin.Android.Aapt2.targets(156,3): error APT2061: failed linking file resources.
1>Done building project "ParadigmaN.Apps.ControlN.csproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 2 up-to-date, 0 skipped ==========
========== Deploy: 0 succeeded, 0 failed, 0 skipped ==========
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.
Tks for a big effort. Maui is great project.
This is a critical issue for enterprise apps!!!! Please take care about it.
https://developer.android.com/training/articles/security-config
Does this work with a plain .NET6 Android app ?
Does this work with a plain .NET6 Android app ?
Sorry but don't understand "plain ..NET6 Android app".
If you create an application that is not MAUI but just android
If you create an application that is not MAUI but just android
I'm working just with maui. not tryed just android. My first release is for android but must work on windows and IOS
It looks like you put the certificate in a folder called my_ca, when it seems like you need to name the certificate file my_ca.
From this page: https://developer.android.com/training/articles/security-config#certificates
src a raw resource ID pointing to a file containing X.509 certificates.
Besides that, the project you shared seems to have a few different attempts to work out the correct location to put this.
The correct location for Android raw resources is Platforms/Android/Resources/raw. They must also have a build action of AndroidResource (this should be the default for Platforms/Android/Resources/**/*.
I forked the repo and fixed it here: https://github.com/GalaxiaGuy/mauibug_trusted_roots/
I can't confirm the certificate works, but it now builds without an error about a missing resource.
Hi
It looks like you put the certificate in a folder called
my_ca, when it seems like you need to name the certificate filemy_ca.From this page: https://developer.android.com/training/articles/security-config#certificates
src a raw resource ID pointing to a file containing X.509 certificates.
Besides that, the project you shared seems to have a few different attempts to work out the correct location to put this.
The correct location for Android raw resources is
Platforms/Android/Resources/raw. They must also have a build action ofAndroidResource(this should be the default forPlatforms/Android/Resources/**/*.I forked the repo and fixed it here: https://github.com/GalaxiaGuy/mauibug_trusted_roots/
I can't confirm the certificate works, but it now builds without an error about a missing resource.
Great news for me. I'm going to do it
Tks for help.
I was reading https://developer.android.com/training/articles/security-config#LimitingCas or https://developer.android.com/training/articles/security-config#ConfigCustom
If you have more than one cert means all them must be on raw folder ?
I believe in the case of multiple certificates, they should all be in one file. For PEM format, it looks like you just concatenate them:
https://stackoverflow.com/questions/36043272/can-i-combine-multiple-certs-into-one-without-the-private-key
Closing as the answer is up in the thread about placing the files in the correct location (thanks!)