gpt4 book ai didi

ssl - 将 CA 签名证书导入 JKS

转载 作者:太空宇宙 更新时间:2023-11-03 13:12:06 25 4
gpt4 key购买 nike

我从 CA 得到了 4 个 .crt 文件,如下所示,

AddTrustExternalCARoot.crt
COMODORSADomainValidationSecureServerCA.crt
COMODORSAAddTrustCA.crt
demo_site_domain.crt

第二个和第三个是中级证书。我想将 .crt 文件导入 wso2carbon.jks 存储并将其替换为记录在案的 wso2 服务器的现有 jks here .我的问题是,文档需要 wso2carbon 作为别名,但我只能使用该别名导入一个证书,因此我应该导入哪个 .crt 文件?或者我应该导入一个由以上四个 crt 文件创建的复合 .crt 文件(这可能吗?)我尝试使用 AddTrustExternalCARoot.crtdemo_site_domain.crt 但在 wso2 服务器中设置 .jks 文件后,服​​务器 url 出现以下错误,

Secure Connection Failed

The connection to ip:port was interrupted while the page was loading.

The page you are trying to view cannot be shown because the authenticity of the received data could not be verified.
Please contact the website owners to inform them of this problem.

我在这里做错了什么?

我正在使用的 wso2 服务器是 WSO2 UES 我必须将密码放在以下四个文件中以克服 Caused by: java.io.IOException: Keystore was tampered with , 或密码不正确 错误。

repository/conf/security/cipher-text.properties
repository/conf/identity.xml
repository/conf/carbon.xml
repository/conf/tomcat/catalina-server.xml

更新:

我遵循给出的答案,但最后一条命令没有给出 installed in keystore 而是 Certificate was added to keystore以下是我的命令和回复,

keytool -importcert -keystore wso2carbon.jks -file AddTrustExternalCARoot.crt -alias commoroot -trustcacerts

输入 keystore 密码:
重新输入新的密码:别名下的证书已存在于系统范围的 CA keystore 中你还想把它添加到你自己的 keystore 吗? [否]:是证书已添加到 keystore

keytool -importcert -keystore wso2carbon.jks -file COMODORSAAddTrustCA.crt -alias commointermediate1

输入 keystore 密码:
证书已添加到 keystore

keytool -importcert -keystore wso2carbon.jks -file COMODORSADomainValidationSecureServerCA.crt -alias commointermediate2

输入 keystore 密码:
证书已添加到 keystore

keytool -importcert -keystore wso2carbon.jks -file demo_site_domain.crt -alias wso2carbon

输入 keystore 密码:
证书已添加到 keystore

最佳答案

(Meta:我很确定这是重复的,但我找不到合适的。无论如何都要回答。)

That page似乎缺少 keytool 命令行选项和 PEM 文件格式所需的所有破折号;假设您已经纠正了这一点:

在第 3 项中,它说“您可能必须导入任何中间证书......然后才能导入您的 [CA-] 签名证书”。事实上,你知道。有两种方法可以做到这一点:

1:导入每个证书除了您的服务器(或其他终端实体)证书,从上到下,到 keystore 中的单独条目;对于你的情况:

keytool -importcert -keystore wso2carbon.jks -file AddTrustExternalCARoot -alias somealias1 -trustcacerts
keytool -importcert -keystore wso2carbon.jks -file COMODORSAAddTrustCA.crt -alias somealias2
keytool -importcert -keystore wso2carbon.jks -file COMODORSADomainValidationSecureServerCA.crt -alias somealias3

其中 somealias{1,2,3} 是彼此不同的别名,并且不同于 keystore 中已有的任何别名,尤其是 wso2carbon(编辑)(弄清楚如何正确格式化代码行)

然后将您的服务器证书导入到同一 keystore 文件中的(编辑)相同别名,其中 -genkeypair- certreq 先前完成(或者替代为别名,该别名是 先前创建 的 PrivateKey 条目的副本在此 keystore 中通过 -genkeypair-certreq):keytool -importcert -keystore wso2carbon.jks -file demo_site_domain.crt -alias wso2carbon这个(最后)步骤应该说Certificate reply was installed in keystore NOT Certificate was added to keystore。否则它实际上失败了,即使它没有给出错误消息。

2:将所有证书连接到一个文件中,首先是服务器 (EE) 证书,然后将该组合文件导入到(编辑)使用的同一 keystore 文件中的相同别名较早的(或该私钥条目的副本):

# assuming any kind of Unix
cat demo_site_domain.crt COMODORSADomainValidationSecureServerCA.crt \
COMODORSAAddTrustCA.crt AddTrustExternalCARoot.crt >combinedfile
# if Windows use copy a+b+etc or (for PEM) cut&paste in a plaintext editor like Notepad
keytool -importcert -keystore wso2carbon.jks -file combinedfile -alias wso2carbon -trustcacerts

除第一个之外的证书顺序实际上并不重要在这里,但它们将存储在 keystore 中并以“向上”顺序用于 SSL/TLS 协议(protocol),所以我使用cat 中的顺序是为了保持一致性和清晰度。

(编辑) 如果在任何时候对给定 keystore 文件中有或没有的条目有任何疑问,您可以使用 keytool -list -v - 列出它们 keystore 文件名。您使用 -genkeypair 生成的任何条目都是一个 PrivateKey 条目,并且将包含 either keytool< 自动生成的自签名证书 您从 CA 获得的带有链的证书。显示格式相当杂乱,可能会造成混淆,但请查找像 Certificate[1]: Certificate[2]: 等行,紧接着是 Owner:(在标准术语中表示 Subject)和 Issuer:。另一方面,您单独导入的每个 CA 根证书或中间证书将是一个仅包含该证书的 trustedCert 条目。

该页面还说您需要将“签名证书”导入 client-truststore.jks。我相信那是错误的。您通常需要在任何客户端信任库中放置一个自签名证书,但您不需要为由知名 CA 签名的证书执行此操作,Comodo/Addtrust 是.但是,向信任库添加不必要但有效的证书没有什么坏处

关于ssl - 将 CA 签名证书导入 JKS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31948701/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com