无法将证书导入到Java控制面板中 [英] Cannot import certificate into java control panel

查看:2055
本文介绍了无法将证书导入到Java控制面板中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

  keytool -genkey -keyalg RSA -keysize 2048 -keystore test_keystore.jks  - 别名测试

然后生成CSR控制面板作为输入的CSR文件

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

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



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

  java.io.IOException:toDerInputStream拒绝标签类型45 
at sun.security.util.DerValue.toDerInputStream(未知源)
at sun.security.pkcs12.PKCS12KeyStore.engineLoad(未知源)
at java.security.KeyStore.load(未知源)
at com.sun.deploy.panel.CertificatesDialog.importPKCS12Certificate(未知源)
at com.sun.deploy.panel.CertificatesDialog.importButtonActionPerformed(未知源)
at com.sun.deploy.panel .CertificatesDialog.access $ 200(未知源)
at com.sun.deploy.panel.CertificatesDialog $ 4.actionPerformed(未知源)
at javax.swing.AbstractButton.fireActionPerformed(未知源)
在javax.swing.AbstractButton $ Handler.actionPerformed(未知源)
在javax.swing.DefaultButtonModel.fireActionPerformed(未知源)
at javax.swing.DefaultButtonModel.setPressed(未知来源)
在javax.swing.plaf.basic.BasicButtonListener.mouseReleased(未知源)
在java.awt.AWTEventMulticaster.mouseReleased(未知源)
在java.awt.Component.processMouseEvent(未知来源)
at javax.swing.JComponent.processMouseEvent(未知源)
at java.awt.Component.processEvent(未知源)
at java.awt.Container.processEvent(未知源)
在java.awt.Component.dispatchEventImpl(未知源)
在java.awt.Container.dispatchEventImpl(未知源)
在java.awt.Component.dispatchEvent(未知源)
在java .awt.LightweightDispatcher.retargetMouseEvent(未知源)
at java.awt.LightweightDispatcher.processMouseEvent(未知源)
at java.awt.LightweightDispatcher.dispatchEvent(未知源)
at java.awt .Container.dispatchEventImpl(未知源)
at java.awt.Window.dispatchEventImpl(未知源)
at java.awt.Component.dispatchEvent(未知源)
at java.awt.EventQueue .dispatchEventImpl(未知源)
at java.awt.EventQueue.access $ 200(未知源)
at java.awt.EventQueue $ 3.run(未知源)
at java.awt.EventQueue $ 3.run(未知源)
在java.security.AccessController.doPrivileged(本地方法)
在java.security.ProtectionDomain $ 1.doIntersectionPrivilege(未知源)
在java.security.ProtectionDomain $ 1.doIntersectionPrivilege(未知源)
在java.awt.EventQueue $ 4.run(未知源)
在java.awt.EventQueue $ 4.run(未知源)
在java.security。 AccessController.doPrivileged(Native方法)
在java.security.ProtectionDomain $ 1.doIntersectionPrivilege(未知源)
在java.awt.EventQueue.dispatchEvent(未知源)
在java.awt.EventDispatchThread .pumpOneEventForFilters(未知源)
在java.awt.EventDispatchThread.pumpEventsForFilter(未知源)
在java.awt.EventDispatchThread.pumpEventsForFilter(未知源)
在java.awt.WaitDispatchSupport $ 2。运行(未知源)
at java.awt.WaitDispatchSupport $ 4.run(未知源)
at java.security.AccessController.doPrivileged(Native方法)
at java.awt.WaitDispatchSupport.enter (未知源)
at java.awt.Dialog.show(未知源)
at java.awt.Component.show(未知源)
at java.awt.Component.setVisible源)
at java.awt.Window.setVisible(未知源)
at java.awt.Dialog.setVisible(未知源)
at com.sun.deploy.panel.SecurityPanel.certsBtnActionPerformed (未知源)
at com.sun.deploy.panel.SecurityPanel.access $ 300(未知源)
at com.sun.deploy.panel.SecurityPanel $ 4.actionPerformed(未知源)
在javax.swing.AbstractButton.fireActionPerformed(未知源)
在javax.swing.AbstractButton $ Handler.actionPerformed(未知源)
在javax.swing.DefaultButtonModel.fireActionPerformed(未知来源)
在javax.swing.DefaultButtonModel.setPressed(未知源)
在javax.swing.plaf.basic.BasicButtonListener.mouseReleased(未知源)
在java.awt.AWTEventMulticaster.mouseReleased(未知来源)
at java.awt.Component.processMouseEvent(未知源)
at javax.swing.JComponent.processMouseEvent(未知源)
at java.awt.Component.processEvent(未知源)
在java.awt.Container.processEvent(未知源)
在java.awt.Component.dispatchEventImpl(未知源)
在java.awt.Container.dispatchEventImpl(未知源)
在java .awt.Component.dispatchEvent(未知源)
at java.awt.LightweightDispatcher.retargetMouseEvent(未知源)
at java.awt.LightweightDispatcher.processMouseEvent(未知源)
at java.awt .LightweightDispatcher.dispatchEvent(未知源)
at java.awt.Container.dispatchEventImpl(未知源)
at java.awt.Window.dispatchEventImpl(未知源)
at java.awt.Component .dispatchEvent(未知源)
at java.awt.EventQueue.dispatchEventImpl(未知源)
at java.awt.EventQueue.access $ 200(未知源)
at java.awt.EventQueue $ 3 .run(未知源)
at java.awt.EventQueue $ 3.run(未知源)
at java.security.AccessController.doPrivileged(Native方法)
at java.security.ProtectionDomain $ 1 。未知来源)
at java.security.ProtectionDomain $ 1.doIntersectionPrivilege(未知源)
at java.awt.EventQueue $ 4.run(未知源)
at java.awt.EventQueue $ 4.run(未知源)
在java.security.AccessController.doPrivileged(本地方法)
在java.security.ProtectionDomain $ 1.doIntersectionPrivilege(未知源)
在java.awt.EventQueue .dispatchEvent(未知源)
at java.awt.EventDispatchThread.pumpOneEventForFilters(未知源)
at java.awt.EventDispatchThread.pumpEventsForFilter(未知源)
at java.awt.EventDispatchThread.pumpEventsForHierarchy (未知源)
at java.awt.EventDispatchThread.pumpEvents(未知源)
at java.awt.EventDispatchThread.pumpEvents(未知源)
at java.awt.EventDispatchThread.run来源)

我做错了什么?

解决方案

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



从stacktrace中的这些行

 在java.security.KeyStore.load(未知源)
at com.sun.deploy.panel.CertificatesDialog.importPKCS12Certificate(未知源)



我可以告诉UI 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

或者keystore可以以指定 -storetype

的PKCS#

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

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


I am trying to import a self-signed certificate into the trusted certificates in the java control panel. it is under the security tab-> Manage Certificates. No matter how simple the password is i set on the keystore, the import program always tells me my password is invalid after i type it in. I have also tried changing the certificate type but no luck..li tried all of them. Here are the simple steps i used to create my files

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

Then I generate my CSR file which the java control panel takes as an input

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

Since this is just a test, the passwords I am setting are super simple so its not an issue of using the wrong password or typing it incorrectly. Yet every time i import the test_certificate_request.csr file i created it it tells me invalid password.

In case it matters, here is the full strack trace generated from the import program when i click on the "more information" button.

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)

What am i doing wrong?

解决方案

keytool -certreq creates certificate request also known as PKCS#10, which should be provided to Certificate Authority to get a real certificate. Then you upload it to the tool, which expects certificate.

From these lines in the stacktrace

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

I can tell that UI actually expects keystore in PKCS#12 format with certificate inside, not just a separate certificate.

This is how you can generate a keystore with self-signed certificate with a keytool

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

However, this will create keystore in JKS format and that have to be converted to PKCS#12 format with a command

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

or alternatively keystore can be created in PKCS#12 format with specifying -storetype

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

Note that the keystore contains self-singed certificate together with the corresponding private key.

这篇关于无法将证书导入到Java控制面板中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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