【发布时间】:2020-01-12 06:51:44
【问题描述】:
我的本地存储 (C:\Users\Certs\cert.p7b) 中有 .p7b 文件。 This 解决方案对我不起作用。
我尝试了以下方法。
File file = new File("C:\Users\Certs\cert.p7b");
BufferedInputStream bis = null;
try {
byte[] buffer = new byte[(int) file.length()];
DataInputStream in = new DataInputStream(new FileInputStream(file));
in.readFully(buffer);
in.close();
CertificateFactory certificatefactory = CertificateFactory.getInstance("X.509");
X509Certificate cert = certificatefactory.getCertificate(in);
}catch (Exception e){
System.out.println("Exception");
}
但它不起作用。那么如何加载这个 .p7b 文件,然后将其存储在密钥库中。
【问题讨论】:
-
可能duplicate?
-
我已经提到,上述重复的答案对我没有帮助。
-
您遇到的错误是什么?
-
我收到此错误
java.security.cert.CertificateException: Could not parse certificate: java.io.IOException: Stream Closed
标签: java x509certificate keystore p7b