java keytool将pkcs12密钥库报告为'jks'

k10s72fa  于 2023-08-02  发布在  Java
关注(0)|答案(2)|浏览(178)

keytool将Keystore type报告为JKS。应该是PKCS12

$ $(dirname $(readlink -f $(which keytool)))/java -version
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
$ keytool -genkey -storetype PKCS12 -keystore foo.p12 -dname "CN=foo" -storepass password -keypass password
$ keytool -list -keystore foo.p12 -storepass password

Keystore type: JKS
Keystore provider: SUN

Your keystore contains 1 entry

mykey, 18/10/2017, PrivateKeyEntry,
Certificate fingerprint (SHA1): FD:2A:C7:EE:B4:D8:41:91:71:25:C2:3F:8D:89:11:6F:F8:D6:F3:73

字符串
这是创建pkcs12密钥库的正确方法吗?

raogr8fs

raogr8fs1#

无法复制:

C:\Temp>keytool -genkey -storetype PKCS12 -keystore foo.p12 -dname "CN=foo" -storepass password -keypass password

C:\Temp>keytool -list -keystore foo.p12 -storepass password
keytool error: java.io.IOException: Invalid keystore format

C:\Temp>java -version
java version "1.8.0_40"
Java(TM) SE Runtime Environment (build 1.8.0_40-b26)
Java HotSpot(TM) Client VM (build 25.40-b25, mixed mode, sharing)

C:\Temp>keytool -list -keystore foo.p12 -storepass password -storetype PKCS12

Keystore type: PKCS12
Keystore provider: SunJSSE

Your keystore contains 1 entry

mykey, 18/10/2017, PrivateKeyEntry,
Certificate fingerprint (SHA1): 3F:C2:78:0D:E5:8D:11:68:2E:EB:31:D3:65:53:69:9F:
87:65:63:3A

字符串
这是创建pkcs12密钥库的正确方法吗?
是的,但这不是正确的方式列出它。你需要-storetype PKCS12,就像我上面的最后一个例子一样。

798qvoo8

798qvoo82#

-storetype <安全属性文件中“keystore.type”属性的值,该值由java.security.KeyStore中的静态getDefaultType方法返回>
如果检查java.security文件,您可能会看到keystore.type的默认值是jks。“keystore type”是由www.example.com文件中分配的值java.security而不是从keystore本身中提取的。

相关问题