How to access certificate from eToken in java

吃可爱长大的小学妹 提交于 2019-12-05 02:15:28

问题


I want to read certificate from eToken when it plugged-in, when I store that certificate on local machine I can read it through my java application but, I don't know how to read it from eToken.

RSAPublicKey pub;
            String fileName = "C:\\myCert.cer";

             InputStream inStream = new FileInputStream(fileName);
             CertificateFactory cf = CertificateFactory.getInstance("X.509");
             X509Certificate cert =
        (X509Certificate)cf.generateCertificate(inStream);
             inStream.close();

             pub = (RSAPublicKey) cert.getPublicKey();
             System.out.println(cert.getIssuerDN());
             System.out.println(cert.getSubjectDN());
             System.out.println(cert.getSubjectAlternativeNames());
             byte [] tempPub = pub.getEncoded();
             String sPub = new String( tempPub );

回答1:


One way to do this is by using the PKCS#11 provider. It comes with examples, too.



来源:https://stackoverflow.com/questions/8120160/how-to-access-certificate-from-etoken-in-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!