本文介绍了如何从eToken在java中访问证书的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在eToken插入时读取证书,当我在本地机器上存储证书时,可以通过我的java应用程序读取它,但我不知道如何从eToken读取它。
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 );
推荐答案
一种方法是使用。它也有例子。
One way to do this is by using the PKCS#11 provider. It comes with examples, too.
这篇关于如何从eToken在java中访问证书的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!