PFX 到 JKS 键工具转换:别名 <*> 不存在



我正在尝试使用键盘将x.pfx文件转换为x.jks文件,但我得到以下错误:

keytool error: java.lang.Exception: Alias <2> does not exist

此错误之前的操作是:

列表x.pfx文件内容(只是阅读别名名称):

keytool -v -list -storetype pkcs12 -keystore x.pfx
Enter keystore password: x
Keystore type: PKCS12   
Keystore provider: SunJSSE
Your keystore contains 1 entry
Alias name: 2
Creation date: 11-nov-2012
Entry type: PrivateKeyEntry
Certificate chain length: 3
Certificate[1]:
Owner: CN=x, OU=x, C=x
Issuer: CN=x, O=x, C=x
Serial number: x
Valid from: Wed Oct 24 11:46:10 CEST 2012 until: Fri Dec 13 09:28:40 CET 2013
Certificate fingerprints:
etc.

使用" 2"作为源别名名称

将x.pfx文件转换为x.jks文件
keytool -importkeystore -srckeystore x.pfx -srcstoretype pkcs12 -srcalias 2 -destkeystore x.jks -deststoretype jks -destalias xyz
Enter destination keystore password: y
Re-enter new password: y
Enter source keystore password: x
keytool error: java.lang.Exception: Alias <2> does not exist

我不确定我在做什么错吗?PFX文件仅包含一个只有一个别名(2)的条目。我还尝试使用这些srcalias值:2," 2"," 2"。还有其他方法可以使用keytool不知道源别名名称将PFX转换为JK吗?

我遇到了完全相同的问题。我使用" 1"而不是2.不知道为什么解决了。

如果在pkcs12中设置别名:

openssl pkcs12 -export -in certificate.pem -inkey private_key.pem -out keystore.p12 -name "myalias"

aftet别名成功设置:

keytool -importkeystore -srckeystore keystore.p12 -srcstoretype pkcs12 -destkeystore keystore.jks -deststoretype JKS -alias myalias

您的命令应该看起来更像

keytool -importkeystore -srckeystore x.pfx -srcstoretype pkcs12 -***alias*** 2 -destkeystore x.jks -deststoretype jks -destalias xyz

也许是" 2",因为其中包含Whiteves(例如" 2")

如果您不想更改别名,只需删除选项 -srcalias -destalias ,它将与原始别名导入。

您可以使用Keytool列出*.pfx文件中的别名,只需使用以下命令:

keytool -list -keystore yourPrivateCertificate.pfx

这将为您提供类似的东西:

Enter keystore password:
Keystore type: jks
Keystore provider: SUN
Your keystore contains 1 entry
253db30c3ad14553aebb0e5a0a5255d0_e5345748-fe48-42ac-81e7-b48cfb4610dd, Nov 25, 2019, PrivateKeyEntry,
Certificate fingerprint (SHA1): 
A9:3B:80:3C:D9:63:0E:FF:91:72:AC:11:4B:45:99:14:9E:AD:EC:FB

因此,在上面的情况下,以下是别名:

253db30c3ad14553aebb0e5a0a5255d0_e5345748-fe48-42ac-81e7-b48cfb4610dd

此值需要用于源别名

相关内容

最新更新