如何使用Java从证书获取RFC822电子邮件ID数据

时间:2018-08-13 11:07:49

标签: java

我正在从USB令牌读取证书,

KeyStore ks = KeyStore.getInstance("Windows-MY");
ks.load(null, null) ;
Enumeration en = ks.aliases() ;
while (en.hasMoreElements()) {
    String aliasKey = (String)en.nextElement() ;
    Certificate c = ks.getCertificate(aliasKey) ;
    System.out.println("---> alias : " + aliasKey) ;
    if (ks.isKeyEntry(aliasKey)) {
        Certificate[] chain = ks.getCertificateChain(aliasKey);
        System.out.println("---> chain length: " + chain.length);
        for (Certificate cert: chain) {
            System.out.println(cert);
    }
}

我想使用Java读取RFC822电子邮件ID证书数据。

1 个答案:

答案 0 :(得分:0)

byte[] value = certificate.getExtensionValue("2.5.29.17");
email = new String(value, "UTF-8");