Search code examples
javaandroidsslacra

Unable to make ACRA accept a self-signed certificate


ACRA set up with standard options:

@ReportsCrashes(
        formUri = "https://XXXXXXXXXX.php",
        mode = ReportingInteractionMode.TOAST,
        resToastText = R.string.str_acra_crash_report_info)

Tried to copy the server certificate to assets and create a custom KeyStore:

try {
    KeyStore ksTrust = KeyStore.getInstance("BKS");
    InputStream instream = new BufferedInputStream(getAssets().open("keystore.bks"));
    ksTrust.load(instream, "ez24get".toCharArray());
    ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(this);
    configurationBuilder.setKeyStore(ksTrust);
    final ACRAConfiguration config = configurationBuilder.build();
    ACRA.init(this, config);
} catch (KeyStoreException | IOException | NoSuchAlgorithmException | CertificateException e) {
    e.printStackTrace();
}

or another way:

CertificateFactory cf = CertificateFactory.getInstance("X.509");
InputStream caInput = new BufferedInputStream(getAssets().open("ssl-cert-snakeoil.pem"));
Certificate ca = cf.generateCertificate(caInput);
String keyStoreType = KeyStore.getDefaultType();
KeyStore keyStore = KeyStore.getInstance(keyStoreType);

Unfortunately after hours of tests, still no luck, still getting an exception:

java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.

Any hints?

EDIT: Created another certificate, with CA:TRUE (standard ssl-cert-snakeoil.pem had CA:FALSE), but still no luck.

EDIT 2: Certificates made as they should be: main CA cert. + server cert., but still the same exception.


Solution

  • @Matthew you will need to use the head of the ACRA's master as it has this https://github.com/ACRA/acra/pull/388 pull request added.

    We'll probably cut another release within a week or so.