简体   繁体   English

使用密钥文件将.pem转换为jks

[英]convert .pem to jks with out key file

i am trying to convert .pem file to .jks but i am unable to do it. 我正在尝试将.pem文件转换为.jks,但我无法做到。 the cert.pem has passphrase only but not any key file. cert.pem仅具有密码短语,但没有任何密钥文件。

i tried this: 我尝试了这个:

openssl pkcs12 -export -nokeys -in cert.pem -out cert.p12

keytool -importkeystore -srckeystore cert.p12 -srcstoretype pkcs12 -srcstorepass login1 -destkeystore trustStore.jks

and i got : 我得到了:

Import command completed: 0 entries successfully imported, 0 entries failed or cancelled . Import command completed: 0 entries successfully imported, 0 entries failed or cancelled

and created trustStore.jks is empty. 并且创建的trustStore.jks为空。

how to do it? 怎么做?

When you have a certificate file (.pem file), you usually add it to a keystore, but not convert it. 拥有证书文件(.pem文件)时,通常将其添加到密钥库中,但不进行转换。

In order to add a certificate to a keystore (new/existing), you can run this keytool command: 为了将证书添加到密钥库(新的/现有的),可以运行以下keytool命令:

keytool -importcert -keystore "KEYSTORE_FILE" -storepass "KEYSTORE_PASSWORD" -file "CERTIFICATE_FILE" -alias "CERTIFICATE_ALIAS" keytool -importcert -keystore“ KEYSTORE_FILE” -storepass“ KEYSTORE_PASSWORD”-文件“ CERTIFICATE_FILE”-别名“ CERTIFICATE_ALIAS”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM