'how to dynamic download and use self-signed CA in networkSecurityConfig at runtime when develop android release app

I'm developing android mobile app, allow user to connect with their own server. Sometimes customer configure self-signed certificate on their server, android mobile app need to support connect with that server. I refer to google guide https://developer.android.com/training/articles/security-config, use networkSecurityConfig allow user imported certificate, but when I try to publish to google play, it is rejected, user level certificate is not allowed in release version. But server side certificate is not fixed at build time, cannot bundled in android apk, I want a way at runtime, dynamically download and allow the traffic to the self-signed certificated server. Does anyone have similar requirement? or any clue?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source