0
ACRA設置了標準選項:無法使ACRA接受自簽名證書
@ReportsCrashes(
formUri = "https://XXXXXXXXXX.php",
mode = ReportingInteractionMode.TOAST,
resToastText = R.string.str_acra_crash_report_info)
試圖複製服務器證書的資產,並創建一個自定義密鑰庫:
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();
}
或其他方式:
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);
不幸經過幾個小時的測試,仍然沒有運氣,仍然收到異常:
java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
任何提示?
編輯:創建另一個證書,CA:TRUE(標準ssl-cert-snakeoil.pem的CA:FALSE),但仍然沒有運氣。
編輯2:證書應該是:主CA證書。 +服務器證書,但仍然是相同的例外。
它到底如何工作? – StefanTo
我切換到標準證書。 – Matthew