e227. getting the subject and issuer distinguished names of an x509 certificate.txt

来自「这里面包含了一百多个JAVA源文件」· 文本 代码 · 共 24 行

TXT
24
字号
This example lists the subject and issuer distinguished names of the certificates in a keystore. To load a keystore, see e208 Listing the Aliases in a Key Store. 
    try {
        // List the aliases
        Enumeration enum = keystore.aliases();
        for (; enum.hasMoreElements(); ) {
            String alias = (String)enum.nextElement();
    
            java.security.cert.Certificate cert = keystore.getCertificate(alias);
            if (cert instanceof X509Certificate) {
                X509Certificate x509cert = (X509Certificate)cert;
    
                // Get subject
                Principal principal = x509cert.getSubjectDN();
                String subjectDn = principal.getName();
    
                // Get issuer
                principal = x509cert.getIssuerDN();
                String issuerDn = principal.getName();
            }
        }
    } catch (KeyStoreException e) {
    }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?