加载KeyStore(PKCS12)时出错 [英] Error loading KeyStore(PKCS12)

查看:3213
本文介绍了加载KeyStore(PKCS12)时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用load方法加载KeyStore,但是当我使用它时出现错误.我不知道什么是ECParameter.

I want to load a KeyStore with the load method but when I use it I got an error. I don't understant what ECParameter is.

try {
FileInputStream is =new FileInputStream(new File("D:\\UZ\\key_privateUZ.p12"));
ks = KeyStore.getInstance("PKCS12");
password="1234".toCharArray();
ks.load(is, password);
} catch (Exception e) {
e.printStackTrace();
}

我的错误:

java.security.cert.CertificateParsingException: java.io.IOException: Only named ECParameters supported 
at sun.security.x509.X509CertInfo.<init>(X509CertInfo.java:171) 
at sun.security.x509.X509CertImpl.parse(X509CertImpl.java:1788) 
at sun.security.x509.X509CertImpl.<init>(X509CertImpl.java:202) 
at sun.security.provider.X509Factory.engineGenerateCertificate(X509Factory.java:97) 
at java.security.cert.CertificateFactory.generateCertificate(CertificateFactory.java:339) 
at sun.security.pkcs12.PKCS12KeyStore.loadSafeContents(PKCS12KeyStore.java:1441) 
at sun.security.pkcs12.PKCS12KeyStore.engineLoad(PKCS12KeyStore.java:1313) 
at java.security.KeyStore.load(KeyStore.java:1214) 
at Main.main(Main.java:21) Caused by: java.io.IOException: Only named ECParameters supported 
at sun.security.ec.ECParameters.decodeParameters(ECParameters.java:202) 
at sun.security.ec.ECParameters.engineInit(ECParameters.java:319) 
at java.security.AlgorithmParameters.init(AlgorithmParameters.java:293) 
at sun.security.x509.AlgorithmId.decodeParams(AlgorithmId.java:139) 
at sun.security.x509.AlgorithmId.<init>(AlgorithmId.java:114) 
at sun.security.x509.AlgorithmId.parse(AlgorithmId.java:381) 
at sun.security.x509.X509Key.parse(X509Key.java:168) 
at sun.security.x509.CertificateX509Key.<init>(CertificateX509Key.java:75) 
at sun.security.x509.X509CertInfo.parse(X509CertInfo.java:705) 
at sun.security.x509.X509CertInfo.<init>(X509CertInfo.java:169) 
... 8 more

瑞格斯

瓦祖尔

推荐答案

如果进行搜索,您将找到有关EC(椭圆曲线)参数的大量信息.特别是,抛出该异常的 JDK代码.

You'll find plenty of information on EC (elliptic curve) parameters if you do a search. In particular, the JDK Code which throws that exception.

如果您查看相关方法,则会在异常之后看到注释掉的部分,表明:

If you look in the relevant method, you will see a commented out section after the exception which indicates:

将其作为完整解析实现的起点

It is left as a starting point for a complete parsing implementation

换句话说,JDK不支持所有可能的编码.

In other words the JDK doesn't support all possible encodings.

使用

You might have better luck using Bouncy Castle which generally has more features than the basic JDK.

如果您解释密钥库中的数据是如何生成的,这也可能会有所帮助.

It might also help if you explain how the data in the keystore was generated.

这篇关于加载KeyStore(PKCS12)时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆