title: Installing CA certificate on android in system context
body: <p>I need to access a REST API by HTTPS from my Xamarin APP. Of course in my development environment, I don't use a publicly signed certificate but signed from my local CA. So I need to add my CA certificate to the trusted CAs on the Android emulator. After some google searches the first approach I've found was, to just drag and drop it into the emulator and then install it with the &quot;Files&quot; app. But this only seems to install it in the user context. Which my App doesn't seem to care about since it still did not accept the certificate from the API as trusted. So I searched for some more...</p>
  <p>The next approach was to get the issuer hash value from the certificate, rename the file after it, disable <code>Google APIs</code> and <code>Google Play Store</code> and do this:</p>
  <pre><code>emulator -avd &lt;avd_name_here&gt; -writable-system
  
  adb root
  adb shell remount
  adb push &lt;cert_filename&gt; /system/etc/security/cacerts
  adb shell &quot;chmod 664 /system/etc/security/cacerts/&lt;cert_filename&gt;&quot;
  
  adb reboot
  </code></pre>
  <p>This did work but has some downsides. Always launch the emulator with <code>-writable-system</code> which means I have to launch it manually instead of from Visual Studio, and keeping <code>Google APIs</code> and <code>Google Play Store</code> disabled. I don't know what difference it makes if I keep those APIs disabled.</p>
  <p>I can't really believe that this is the only way to install a CA certificate. How is it done on a real device? I assume I can't just disable the google APIs there?</p>