Special thanks to Vladimir Vetrov <pdastore1@gmail.com>, who provided a patch that would eventually inform parts of this patch (in particular, how to use some of the certificate-related Android APIs). Differential Revision: https://phabricator.services.mozilla.com/D238821