Ssl 作为PrivateKeyEntry导入证书
我正在Tomcat服务器上安装SSL,并遵循发卡机构的以下说明,它声明:Ssl 作为PrivateKeyEntry导入证书,ssl,keystore,keytool,Ssl,Keystore,Keytool,我正在Tomcat服务器上安装SSL,并遵循发卡机构的以下说明,它声明: Verify the following information: The SSL certificate is imported into the alias with the "Entry Type" of PrivateKeyEntry or KeyEntry. If not, please import the certificate into the Private Key alias. 导入证书(to
Verify the following information:
The SSL certificate is imported into the alias with the "Entry Type" of
PrivateKeyEntry or KeyEntry. If not, please import the certificate into
the Private Key alias.
导入证书(tomcat)时,我使用的是:
keytool -import -trustcacerts -alias your_alias_name -keystore your_keystore_filename
-file your_certificate_filename
但当我这样做时,它将作为trustCertEntry导入
Keystore type: JKS
Keystore provider: SUN
Your keystore contains 3 entries
primaryca, Jul 26, 2014, trustedCertEntry,
Certificate fingerprint (SHA1): <snip>
tomcat, Jul 26, 2014, trustedCertEntry,
Certificate fingerprint (SHA1): <snip>
secondaryca, Jul 26, 2014, trustedCertEntry,
Certificate fingerprint (SHA1): <snip>
Keystore类型:JKS
密钥库提供程序:SUN
您的密钥库包含3个条目
primaryca,2014年7月26日,trustedCertEntry,
证书指纹(SHA1):
tomcat,2014年7月26日,trustedCertEntry,
证书指纹(SHA1):
secondaryca,2014年7月26日,trustedCertEntry,
证书指纹(SHA1):
如何将alias tomcat导入为PrivateKeyEntry?摆脱
-trustcacerts
选项。它不是CA证书。这是你的证书。并使用私钥已有的别名。这些CA指南有点误导@EJP正确地说,您不应该在证书中使用-trustcacerts
此外,此CA文档建议在单独的操作中导入主CA证书和中间CA证书,这将产生如下结果:
primaryca, Jul 26, 2014, trustedCertEntry,
Certificate fingerprint (SHA1): <snip>
secondaryca, Jul 26, 2014, trustedCertEntry,
Certificate fingerprint (SHA1): <snip>
tomcat, Jul 26, 2014, PrivateKeyEntry,
Certificate fingerprint (SHA1): <snip>
primaryca,2014年7月26日,trustedCertEntry,
证书指纹(SHA1):
secondaryca,2014年7月26日,trustedCertEntry,
证书指纹(SHA1):
tomcat,2014年7月26日,PrivateKeyEntry,
证书指纹(SHA1):
不幸的是,像这样在密钥库中导入CA证书是毫无意义的。(这在中可能很有用,但您正在使用的CA可能已经在默认的信任库中。)
将证书的CA证书放在密钥库中确实很有用,以便在需要中间证书时提供完整的证书链。但是,keymanager(除非可能是自定义实现)不会为您构建链,即使它在您的最终实体证书(PrivateKeyEntry中)旁边找到合适的CA证书
您需要将这些证书作为一个链一起导入到私钥所在的条目中。为此,将证书连接在一个文本文件(PEM编码)中,首先是服务器证书,然后是用于颁发证书的证书,依此类推。然后,使用该私钥别名将该文件导入密钥库。(这与中的问题完全相同,但使用的是服务器证书。)
(我不确定您的CA是否已经将您的证书文件作为一个链提供给您,但一般来说,您至少只能在一个文件中获得证书,而在另一个文件中获得中间CA证书。您链接到的文档似乎有误导性,因为它们没有提及--开始/结束证书--
之间的多个块,但不知怎的,它们的示例屏幕截图针对该别名的证书长度为4。)
正如@jww在对您的问题的评论中指出的,您不需要“根”CA证书(自签名证书)在这个链中,因为要么你的客户已经信任它,要么你发送它时它没有理由信任它。将它放在你的链中并没有错,但这是毫无意义的,并且可能会增加一点网络开销。你尝试添加证书,并期望它将是私钥——这是两种不同事物之间的混淆 通常,在创建密钥库(.jks)时,它会在其中包含私钥。 如果其为空(已删除),则应根据密钥和证书生成捆绑包(.p12文件) 为了创建新的免费密钥和证书,您可以使用这个openSSl实现 然后,您得到了一个密钥和证书,您应该从它们生成(.p12)捆绑文件:(在linux机器上) 现在,只需通过执行以下命令将捆绑文件(.p12文件)添加到密钥库(.jks):
keytool -importkeystore -deststorepass [password] -destkeystore [filename-new-keystore.jks] -srckeystore [filename-new-PKCS-12.p12] -srcstoretype PKCS12
您不需要
primaryca
。服务器应发送服务器证书和构建到受信任机构的路径所需的任何中间证书。由客户端信任该机构或primaryca
。如果客户端不信任该机构或primaryca
(除了让他们相信它)。已经澄清-这指的是别名为tomcat的证书,它是服务器的实际证书,而不是任何一个ca证书。这似乎是相关的:。这不起作用,你不能直接这样做!关闭它对我没有影响。这不一定是唯一的问题。
keytool -importkeystore -deststorepass [password] -destkeystore [filename-new-keystore.jks] -srckeystore [filename-new-PKCS-12.p12] -srcstoretype PKCS12