当我试图将证书导入java密钥库时,出现以下异常。
“java.security.cert.certificateparsingexception:der编码的证书数据无效”
FileInputStream fis = new FileInputStream(filename);
BufferedInputStream bis = new BufferedInputStream(fis);
java.security.cert.CertificateFactory cf = java.security.cert.CertificateFactory
.getInstance("X.509");
while (bis.available() > 0) {
Certificate cert = cf.generateCertificate(bis);
if (cert instanceof X509Certificate) {
certFx.addCertificate("vel", (X509Certificate) cert, true);
}
}
任何帮助都将不胜感激!。
1条答案
按热度按时间ubof19bj1#
确保您的证书以
-----BEGIN CERTIFICATE-----
结束于-----END CERTIFICATE-----
. 您的证书应如下所示: