我想让我的 Liberty 应用程序通过 TLS 相互身份验证连接 Bluemix Secure Gateway 的目的地。我尝试创建一个 key 存储并通过 keytool 将证书和 secret key 导入到 key 存储中,但我不知道 secret key 的 key 别名。我无法执行将 key 导入 key 存储的命令。 (证书和 key 由 Bluemix Secure Gateway 的目的地通过 TLS 相互验证 (*) 提供)
*Bluemix 安全网关
https://www.ng.bluemix.net/docs/services/SecureGateway/index.html
你能教我如何知道 key 的 key 别名吗? 或者您可以通过 keytool (不是 java 代码)教我任何其他方式来创建 keystore 并导入 key 和证书,但需要执行以下过程?
[Bluemix Secure Gateway 目标提供的文件]
destination_id_key.pem
destination_id_cert.pem
[过程]
- 创建 keystore 并立即将证书导入 keystore
# keytool -import -file *destination_id*_cert.pem -keystore myKeyStore.jks -storepass 密码 -aliasmutual_cert
- 将 key 导入 key 存储
# keytool -importseckey -keyalias XXXXX -keystore myKeyStore.jks -storepass 密码 -storetype jks -importfile *destination_id*_cert.pem
最佳答案
据我所知,别名值是您设置的名称,用于标识您自己的 keystore 中的特定 key 。 key /证书没有自己的别名,因此完全取决于您使用什么别名。稍后,如果您需要删除该 key /证书,或对其执行某些其他操作,则可以在命令中使用自定义别名。所以你可以这样做:
# keytool -importcert -alias myCustomAlias -file *destination_id*_cert.pem -keystore myKeyStore.jks -storepass password -storetype jks
然后,使用命令 keytool -list -keystore myKeyStore.jks
查看您的 key /证书列表。每个条目将列在您为该 key /证书选择的别名下,例如:
myCustomAlias, 01-Jul-2015, trustedCertEntry,
Certificate fingerprint (SHA1): AA:BB:CC:DD:EE:FF:11:22:33:44:55:66:77:88:99:00:AA:BB:CC:DD
注意:您在示例命令中使用的 -importseckey1
、-keyalias
和 -importfile
不是 keytool 的有效选项。 -importcert
、-alias
和 -file
是正确的选项名称,但它们可能只是您在创建问题时出现的拼写错误。
关于ssl - 如何通过 keytool 将 key 导入 key 存储,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31132288/