Search code examples
google-chrome-arc

How to Install a Certificate With Arc Welder


Trying to launch my app with Arc. My app requires a certain certificate to be installed on the device. Typically I do this through Android settings. How do I install the certificate in Arc?

Thanks


Solution

  • Didn't seem possible, so ultimately I added the certificate as a raw resource and then using the following article, I loaded the certificate through code: http://littlesvr.ca/grumble/2014/07/21/android-programming-connect-to-an-https-server-with-self-signed-certificate/

    All worked well and can now run the app through ARC with use of the cert.

    In case the article goes down in the future, here is the relevant code, with any minor modifications to support:

    protected SSLSocketFactory getCertificateSocketFactory() throws Exception {
    
        InputStream certStrm = context.getResources().openRawResource(R.raw.cert_file)
    
        CertificateFactory cf = CertificateFactory.getInstance("X.509");
        Certificate ca = cf.generateCertificate(certStrm);
    
        String keyStoreType = KeyStore.getDefaultType();
        KeyStore keyStore = KeyStore.getInstance(keyStoreType);
        keyStore.load(null, null);
        keyStore.setCertificateEntry("ca", ca);
    
        String tmfAlgorithm = TrustManagerFactory.getDefaultAlgorithm();
        TrustManagerFactory tmf = TrustManagerFactory.getInstance(tmfAlgorithm);
        tmf.init(keyStore);
    
        SSLContext sslContext = SSLContext.getInstance("TLS");
        sslContext.init(null, tmf.getTrustManagers(), null);
    
        return sslContext.getSocketFactory();
    
    }