I wrote simple helper which allow loading specific certificate to SSLContext.
You can use it to support HTTPS connections which rely on a untrusted certificate.
By untrusted certificate, I mean this one which server is certified but system denies it (doesn’t trust it) for some reason.
I found it very useful to load particular certificate dynamically.
ssh-development-only-certificate.cer. No one should trust it except development-phase client app. The second case: you want to use the web proxy. It’s also risky to install proxy certificate for the whole system.
You can easily adopt that code in any JVM language like Groovy, Kotlin, etc.
On Android you can load certificate from assets. Github repo is here.
See this post on my personal blog.