我尝试使用getAcceptedIssuers()方法来获取Trusted X509Certificate的列表。

X509Certificate[] cert2= getAcceptedIssuers();


在该列表中,“公用名”(Symantec Class 3 EV SSL CA-G3)不可用。
如何在默认的Trust Manager中获得此值?

 @Override
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
    if (!false) {
        X509Certificate cert=chain[0];
        Log.d("bucky validate 0",chain[0].getIssuerDN().getName());
        boolean found = false;
        try {
            String dns= String.valueOf(cert.getIssuerDN());
            Log.d("bucky validate",dns);
            X509Certificate[] cert2= getAcceptedIssuers();
            int length=cert2.length;
            for (int i=0;i<length;i++){
               String dnName= String.valueOf(cert2[i].getIssuerDN());
                Log.d("bucky validate2",dnName);
            }
            cert.checkValidity(new Date());
        } catch (Exception e) {
            e.printStackTrace();
        }}


@Override
public X509Certificate[] getAcceptedIssuers()
{
    return defaultTrustManager.getAcceptedIssuers() ;
}



public ApplicationTrustManager() throws NoSuchAlgorithmException, KeyStoreException {

    TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
    tmf.init((KeyStore) null);
    defaultTrustManager = (X509TrustManager) tmf.getTrustManagers()[0];
}

最佳答案

最后,我得到了答案。它是一个小错误。

     @Override
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException


链数组的最后一个值,我得到了受信任的证书名称。

10-06 11:23