密钥库的 setkeyentity 的参数

发布于 2025-01-03 10:03:29 字数 955 浏览 0 评论 0原文

我使用密钥库来保护文件中的私钥,使用以下代码

ks.setKeyEntry("kk1", pr, pass, cert1);//ks is obj of keystore,
                                       //kk1 is alias,
                                       //pr-->is private key,
                                       //pass->is the password to protect that key,
                                       //cert1-->is the certificate chain..

稍后我想将其存储在文件中,使用存储函数。 我的问题是

  (actual argument java.security.cert.X509Certificate cannot be converted to java.security.cert.Certificate[] by method invocation conversion)

我已经给出了 cert1,因为

 X509V3Create obj=new   X509V3Create();  //it is my own class
 X509Certificate cert1  = obj.generateV3Certificate(pair);
 //in this method I set all the certificate parameters like version,alg etc..,pair is obj of key pair...

我收到了上面提到的错误。我无法将该参数设置为 null(它给出了空指针异常)

我应该传递什么作为参数???

I am using keystore to protect the private key in a file using the following code

ks.setKeyEntry("kk1", pr, pass, cert1);//ks is obj of keystore,
                                       //kk1 is alias,
                                       //pr-->is private key,
                                       //pass->is the password to protect that key,
                                       //cert1-->is the certificate chain..

Later i want to store it in the file,uisng store function.
My problem is

  (actual argument java.security.cert.X509Certificate cannot be converted to java.security.cert.Certificate[] by method invocation conversion)

I have given cert1 as

 X509V3Create obj=new   X509V3Create();  //it is my own class
 X509Certificate cert1  = obj.generateV3Certificate(pair);
 //in this method I set all the certificate parameters like version,alg etc..,pair is obj of key pair...

I am getting the error which I mentioned above..I can't set that parameter to null(it gives null pointer exception)

What should I pass as argument???

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

人生戏 2025-01-10 10:03:29

试试这个:

java.security.cert.Certificate[] certificateChain = new java.security.cert.Certificate[]{cert1}
ks.setKeyEntry("kk1", pr, pass, certificateChain);

Try this:

java.security.cert.Certificate[] certificateChain = new java.security.cert.Certificate[]{cert1}
ks.setKeyEntry("kk1", pr, pass, certificateChain);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文