We saw an influx of the following exceptions and only for Android 7.1.1 (API 25). Has something changed in 7.1.1 to prevent this from happening?
java.security.ProviderException: Failed to load generated key pair from keystore
at android.security.keystore.AndroidKeyStoreKeyPairGeneratorSpi.loadKeystoreKeyPair(AndroidKeyStoreKeyPairGeneratorSpi.java:518)
at android.security.keystore.AndroidKeyStoreKeyPairGeneratorSpi.generateKeyPair(AndroidKeyStoreKeyPairGeneratorSpi.java:470)
Sanitized code below (may have minor errors in the copy folder)
KeyPairGenerator generator = KeyPairGenerator.getInstance("RSA", "AndroidKeyStore");
String certInfo = String.format(Locale.ROOT, "CN=%s, OU=%s", new Object[]{"KeyName", context.getPackageName()});
generator.initialize(new KeyPairGeneratorSpec.Builder(context)).setAlias("KeyName").setSubject(new X500Principal(certInfo)).setSerialNumber(BigInteger.ONE).setStartDate(start).setEndDate(end).build());
generator.generateKeyPair();
source
share