我需要用我的自签名证书链创建一个 .keystore 文件。
我尝试了两种方法。
方法一:
https://blog.didierstevens.com/2008/12/30/howto-make-your-own-cert-with-openssl/
我使用上面的帖子创建了我的自签名证书链。我将 .crt 转换为 .p7b 并尝试创建 keystore 文件,但我在 OpenSSL 中得到“输入不是 X.509 证书”。
我正在使用 Windows 机器。所以我打开了 .crt 文件,单击“复制到文件”并将其另存为 .p7b 文件。
方法二:
https://www.pixelstech.net/article/1450354633-Using-keytool-to-create-certificate-chain
我使用上面的帖子创建了我的带有证书链的 keystore ,但是当我将它添加到 时,我的浏览器中出现“无法访问此站点”错误,并且日志中没有错误。
我的连接器如下:
<Connector SSLEnabled="true" acceptCount="100" clientAuth="false" connectionTimeout="20000" debug="0" disableUploadTimeout="true" enableLookups="false" keystoreFile="test.keystore" keystorePass="test" maxSpareThreads="75" maxThreads="150" minSpareThreads="25" name="SSL" port="9372" scheme="https" secure="true" sslEnabledProtocols="TLSv1,TLSv1.1,TLSv1.2" sslProtocol="TLS"/>
如果 keystore 文件只有一个证书,则上述连接器有效。因此,问题出在生成 keystore 的过程中。
如何成功将证书链添加到我的 keystore ?
编辑:
<Connector SSLEnabled="true" acceptCount="100" clientAuth="false" connectionTimeout="20000" debug="0" disableUploadTimeout="true" enableLookups="false" keystoreFile="test.p12" keystorePass="test" keystoreType="PKCS12" maxSpareThreads="75" maxThreads="150" minSpareThreads="25" name="SSL" port="9372" scheme="https" secure="true" sslEnabledProtocols="TLSv1,TLSv1.1,TLSv1.2" sslProtocol="TLS"/>
我将 keystore 的格式从 .keystore 修改为 .p12。我的应用程序现在运行,但“Didier Stevens 代码签名 (https://DidierStevens.com)”的状态显示“此证书正常”。而“Didier Stevens( https://DidierStevens.com )”的状态显示“此 CA 根证书不受信任,因为它不在受信任的根证书颁发机构存储中。”。应该是相反的,但不知道是什么问题。
最佳答案
您引用了“如果 keystore 文件只有一个证书,上述连接器就可以工作。因此,问题出在生成 keystore 的过程中。” 因此,如果问题是在 keystore 中选择一组特定的证书/ key ,您需要将其指定为连接器的一部分。
如果未指定,将使用第一个条目。
参见此处:https://tomcat.apache.org/tomcat-7.0-doc/config/http.html#Common_Attributes
Attribute keyAlias
The alias used for the server key and certificate in the keystore. If not specified, the first key read from the keystore will be used. The order in which keys are read from the keystore is implementation dependent. It may not be the case that keys are read from the keystore in the same order as they were added. If more than one key is present in the keystore it is strongly recommended that a keyAlias is configured to ensure that the correct key is used.
关于tomcat - 将自签名证书链添加到 keystore ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47979233/