如何通过keytool将密钥导入密钥存储区

时间:2015-06-30 07:35:51

标签: ssl keytool ibm-cloud secure-gateway

我想让我的Liberty应用程序将Bluemix Secure Gateway' sdestination与TLS Mutual Auth连接起来。我试图创建一个密钥库,并通过keytool将证书和密钥导入密钥库,但我不知道密钥的密钥。我无法执行将密钥导入密钥存储区的命令。 (证书和密钥由Bluemix Secure Gateway的目的地提供,使用TLS Mutual Auth(*))

* Bluemix Secure Gateway
https://www.ng.bluemix.net/docs/services/SecureGateway/index.html

你能告诉我如何知道密钥的keyalias吗? 或者你可以通过keytool(而不是java代码)教我任何其他方式创建密钥库并导入密钥和证书但是以下过程?

[Bluemix Secure Gateway&#39目的地提供的文件]
目标_ID _key.pem
目标_ID _cert.pem

[步骤]
1.创建密钥库并立即将证书导入密钥库 # keytool -import -file *destination_id*_cert.pem -keystore myKeyStore.jks -storepass password -alias mutual_cert

2.将密钥n导入密钥库
# keytool -importseckey -keyalias XXXXX -keystore myKeyStore.jks -storepass password -storetype jks -importfile *destination_id*_cert.pem

2 个答案:

答案 0 :(得分:1)

在文档中使用openssl的示例使用目标证书和密钥创建密钥库。

https://www.ng.bluemix.net/docs/services/SecureGateway/sg_023.html#sg_007

答案 1 :(得分:1)

据我所知,别名值是设置的名称,用于标识您自己的密钥库中的特定密钥。密钥/证书没有自己的别名,因此完全取决于您使用的别名。稍后,如果您需要删除该密钥/证书,或对其执行某些其他操作,则可以在命令中使用自定义别名。所以你可以这样做:

# keytool -importcert -alias myCustomAlias -file *destination_id*_cert.pem -keystore myKeyStore.jks -storepass password -storetype jks

然后,使用命令keytool -list -keystore myKeyStore.jks查看密钥/证书列表。每个条目都将列在您为该密钥/证书选择的别名下,例如:

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是正确的选项名称,但在创建问题时,它们可能只是您的错别字。