Skip to content Skip to sidebar Skip to footer

How To Delete User Installed Certificate Programmatically?

I had installed a certificate programmatically. I am able to uninstall it manually by going Settings -> Security -> Trusted Credentials -> User -> Choose the certificat

Solution 1:

Looks like that implementation of the KeyStoreSpi interface just doesn't support removal:

@OverridepublicvoidengineDeleteEntry(String alias) {
    thrownewUnsupportedOperationException();
}

https://android.googlesource.com/platform/external/conscrypt/+/master/src/platform/java/org/conscrypt/TrustedCertificateKeyStoreSpi.java#81

Solution 2:

You can do this in Android 5.x with a device owner using the uninstallCaCert() method. A device owner can be installed only before the device is provisioned though.

https://developer.android.com/reference/android/app/admin/DevicePolicyManager.html#uninstallCaCert(android.content.ComponentName, byte[])

Post a Comment for "How To Delete User Installed Certificate Programmatically?"