我第一次尝试在 tomcat 8 中实现 SSL。
我有 .pem 文件形式的第三方签名 X.509 证书。
然而,当我尝试启动 tomcat 时,配置后出现以下错误:
22-Nov-2017 18:48:01.735 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["https-jsse-nio-8443"] 22-Nov-2017 18:48:01.897 SEVERE [main] org.apache.coyote.AbstractProtocol.init Failed to initialize end point associated with ProtocolHandler ["https-jsse-nio-8443"] java.lang.IllegalArgumentException: java.io.IOException: Alias name [null] does not identify a key entry at ...
以下是我遵循的步骤:
- 将 certificate.pem 重命名为 certificate.p7b。
- 应用以下命令将证书导入 keystore :
D:\keytest2>keytool -import -alias tomcat -trustcacerts -file certificate.p7b -keystore keystore.kdb
输入 keystore 密码:test
重新输入新密码:test
...
...
证书已添加到 keystore
- 检查导入的证书:
D:\keytest2>keytool -list -v -keystore keystore.kd
这给了我以下结果:
keystore 类型:JKS keystore 提供商:SUN
您的 keystore 包含 1 个条目
别名:tomcat 创建日期:2017-11-22 条目类型:trustedCertEntry ... ...
Tomcat 配置:
<Connector port="8443" protocol="HTTP/1.1"
maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
keystoreFile="file:///D:/keytest2/keystore.kdb" keystorePass="test"
clientAuth="false" sslProtocol="TLS">
请指导我哪里做错了。
最佳答案
问题是由于在 tomcat 配置中缺少参数“keyAlias”。
但是输入别名并没有解决我的问题。它开始使用别名而不是 null :) 抛出相同的错误。
根据@dev_thompson_085 的评论,我了解到我缺少此过程的 key 文件。所以我根据 url 尝试使用自签名 X.509 证书:https://www.ibm.com/support/knowledgecenter/en/SSWHYP_4.0.0/com.ibm.apimgmt.cmc.doc/task_apionprem_gernerate_self_signed_openSSL.html
它对这两个文件都非常有效。
关于java - 错误 : Alias name [null] does not identify a key entry during implementing SSL in Tomcat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47436011/