There is described on this page how android is able to select all user certificates and show them in a spinner…
http://source-android.frandroid.com/packages/apps/Settings/src/com/android/settings/vpn2/VpnDialog.java
They use the Method:
private void loadCertificates(Spinner spinner, String prefix, int firstId, String selected) {
Context context = getContext();
String first = (firstId == 0) ? "" : context.getString(firstId);
String[] certificates = mKeyStore.saw(prefix);
if (certificates == null || certificates.length == 0) {
certificates = new String[] {first};
} else {
String[] array = new String[certificates.length + 1];
array[0] = first;
System.arraycopy(certificates, 0, array, 1, certificates.length);
certificates = array;
}
ArrayAdapter<String> adapter = new ArrayAdapter<String>(
context, android.R.layout.simple_spinner_item, certificates);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
for (int i = 1; i < certificates.length; ++i) {
if (certificates[i].equals(selected)) {
spinner.setSelection(i);
break;
}
}
}
with this call:
loadCertificates(mIpsecUserCert, Credentials.USER_CERTIFICATE,
0, mProfile.ipsecUserCert);
now they use Credetials.USER_CERTIFICATE for the Method mKeyStore.saw(String prefix)
thats exactly what im looking for, but i cannot invoke the method saw and its also not mentioned in the android api…
so is there somehow a way of getting the same result for me?
the keystore library is not able of making a difference of user or system certs, and if i want to put all certs in a dropdown list it will cost me a lot of loading time. The other way of typing the subject name of the cert and looping through all certs till its the right one is not really practicable for a non-IT guy, so its crappy to handle for a normal user…
there are almost no references on this topic in the net, thats why im asking google android pro’s on this post only.
thankyou
This is a private API, it cannot be used by third party applications. Why do you want to select a user certificate? You generally want the user’s private key, and the KeyChain API supports letting the user select one of those.