Merge "Insert Android Keystore JCA Provider at the correct position." am: 887d348d7e
am: 5995579f5f
* commit '5995579f5ff1511f4a089dd0537cd634fb615465':
Insert Android Keystore JCA Provider at the correct position.
This commit is contained in:
@@ -97,20 +97,21 @@ public class AndroidKeyStoreProvider extends Provider {
|
|||||||
*/
|
*/
|
||||||
public static void install() {
|
public static void install() {
|
||||||
Provider[] providers = Security.getProviders();
|
Provider[] providers = Security.getProviders();
|
||||||
int bcProviderPosition = -1;
|
int bcProviderIndex = -1;
|
||||||
for (int position = 0; position < providers.length; position++) {
|
for (int i = 0; i < providers.length; i++) {
|
||||||
Provider provider = providers[position];
|
Provider provider = providers[i];
|
||||||
if ("BC".equals(provider.getName())) {
|
if ("BC".equals(provider.getName())) {
|
||||||
bcProviderPosition = position;
|
bcProviderIndex = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Security.addProvider(new AndroidKeyStoreProvider());
|
Security.addProvider(new AndroidKeyStoreProvider());
|
||||||
Provider workaroundProvider = new AndroidKeyStoreBCWorkaroundProvider();
|
Provider workaroundProvider = new AndroidKeyStoreBCWorkaroundProvider();
|
||||||
if (bcProviderPosition != -1) {
|
if (bcProviderIndex != -1) {
|
||||||
// Bouncy Castle provider found -- install the workaround provider above it.
|
// Bouncy Castle provider found -- install the workaround provider above it.
|
||||||
Security.insertProviderAt(workaroundProvider, bcProviderPosition);
|
// insertProviderAt uses 1-based positions.
|
||||||
|
Security.insertProviderAt(workaroundProvider, bcProviderIndex + 1);
|
||||||
} else {
|
} else {
|
||||||
// Bouncy Castle provider not found -- install the workaround provider at lowest
|
// Bouncy Castle provider not found -- install the workaround provider at lowest
|
||||||
// priority.
|
// priority.
|
||||||
|
|||||||
Reference in New Issue
Block a user