Android examples for java.security:Certificate
get Installed User Certificates
import android.util.Log; import java.security.KeyStore; import java.security.cert.X509Certificate; import java.util.ArrayList; import java.util.Enumeration; import java.util.List; public class Main{ private static final String TAG = "Certificate"; public static List<CertificateLocator> getInstalledUserCertificates() { List<CertificateLocator> locators = new ArrayList<CertificateLocator>(); try {/*from www .j av a 2s .com*/ KeyStore ks = KeyStore.getInstance("AndroidCAStore"); ks.load(null, null); Enumeration aliases = ks.aliases(); while (aliases.hasMoreElements()) { String alias = (String) aliases.nextElement(); X509Certificate cert = (X509Certificate) ks .getCertificate(alias); Log.d(TAG, "Subject DN: " + cert.getSubjectDN().getName()); Log.d(TAG, "Subject SN: " + cert.getSerialNumber().toString()); Log.d(TAG, "Issuer DN: " + cert.getIssuerDN().getName()); locators.add(new CertificateLocator(cert.getIssuerDN() .getName(), cert.toString())); } } catch (Exception s) { Log.e("Error", s.getMessage()); } return locators; } }