无法将证书导入java控制面板

我正在尝试将自签名证书导入java控制面板中的受信任证书。 它位于安全选项卡 – >管理证书下。 无论我在密钥库上设置的密码有多简单,导入程序总是告诉我输入后我的密码无效。我也尝试更改证书类型但没有运气..我试了所有这些。 以下是我用来创建文件的简单步骤

keytool -genkey -keyalg RSA -keysize 2048 -keystore test_keystore.jks -alias test 

然后我生成我的CSR文件,java控制面板将其作为输入

 keytool -certreq -alias test -keystore test_keystore.jks -file test_certificate_request.csr 

由于这只是一个测试,我设置的密码非常简单,所以它不是使用错误密码或输入错误的问题。 然而,每当我导入test_certificate_request.csr文件时,我创建它就会告诉我密码无效。

如果重要,这里是我点击“更多信息”按钮时从导入程序生成的完整strack跟踪。

 java.io.IOException: toDerInputStream rejects tag type 45 at sun.security.util.DerValue.toDerInputStream(Unknown Source) at sun.security.pkcs12.PKCS12KeyStore.engineLoad(Unknown Source) at java.security.KeyStore.load(Unknown Source) at com.sun.deploy.panel.CertificatesDialog.importPKCS12Certificate(Unknown Source) at com.sun.deploy.panel.CertificatesDialog.importButtonActionPerformed(Unknown Source) at com.sun.deploy.panel.CertificatesDialog.access$200(Unknown Source) at com.sun.deploy.panel.CertificatesDialog$4.actionPerformed(Unknown Source) at javax.swing.AbstractButton.fireActionPerformed(Unknown Source) at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.setPressed(Unknown Source) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source) at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source) at java.awt.Component.processMouseEvent(Unknown Source) at javax.swing.JComponent.processMouseEvent(Unknown Source) at java.awt.Component.processEvent(Unknown Source) at java.awt.Container.processEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Window.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.EventQueue.dispatchEventImpl(Unknown Source) at java.awt.EventQueue.access$200(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue$4.run(Unknown Source) at java.awt.EventQueue$4.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.WaitDispatchSupport$2.run(Unknown Source) at java.awt.WaitDispatchSupport$4.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.awt.WaitDispatchSupport.enter(Unknown Source) at java.awt.Dialog.show(Unknown Source) at java.awt.Component.show(Unknown Source) at java.awt.Component.setVisible(Unknown Source) at java.awt.Window.setVisible(Unknown Source) at java.awt.Dialog.setVisible(Unknown Source) at com.sun.deploy.panel.SecurityPanel.certsBtnActionPerformed(Unknown Source) at com.sun.deploy.panel.SecurityPanel.access$300(Unknown Source) at com.sun.deploy.panel.SecurityPanel$4.actionPerformed(Unknown Source) at javax.swing.AbstractButton.fireActionPerformed(Unknown Source) at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.setPressed(Unknown Source) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source) at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source) at java.awt.Component.processMouseEvent(Unknown Source) at javax.swing.JComponent.processMouseEvent(Unknown Source) at java.awt.Component.processEvent(Unknown Source) at java.awt.Container.processEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Window.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.EventQueue.dispatchEventImpl(Unknown Source) at java.awt.EventQueue.access$200(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue$4.run(Unknown Source) at java.awt.EventQueue$4.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source) 

我究竟做错了什么?

keytool -certreq创建证书请求,也称为PKCS#10,应提供给证书颁发机构以获取真实证书。 然后将其上传到需要证书的工具。

从堆栈跟踪中的这些行

 at java.security.KeyStore.load(Unknown Source) at com.sun.deploy.panel.CertificatesDialog.importPKCS12Certificate(Unknown Source) 

我可以告诉UI实际上期望PKCS#12格式的密钥库里面有证书,而不仅仅是一个单独的证书。

这是如何使用keytool生成带有自签名证书的密钥库

 keytool -genkey -keyalg RSA -alias selfsigned -keystore keystore.jks \ -storepass password -validity 360 -keysize 2048 

但是,这将创建JKS格式的密钥库,并且必须使用命令将其转换为PKCS#12格式

 keytool -importkeystore -srckeystore keystore.jks -srcstoretype JKS \ -deststoretype PKCS12 -destkeystore keystore.p12 

或者,可以使用指定-storetype以PKCS#12格式创建密钥库

 keytool -genkey -keyalg RSA -alias selfsigned -keystore keystore.p12 \ -storetype pkcs12 -storepass password -validity 360 -keysize 2048 

请注意,密钥库包含自签名证书以及相应的私钥。