使用 BouncyCastle 阅读 JKS
Read JKS with BouncyCastle
我有一个 Java KeyStore (JKS),我需要用 BouncyCastle 读取它。
我已将 BC
个提供商添加到提供商列表的顶部:
Security.insertProviderAt(new BouncyCastleProvider(), 1);
如果我这样创建 KeyStore:
final KeyStore keystore = KeyStore.getInstance("JKS", "BC");
我收到一个错误:
java.security.KeyStoreException: JKS not found
如果我不指定提供商,KeyStore 将使用 Sun
提供商创建,keystore.aliases()
将包含 EmptyEnumeration
.
正如我在 this 主题中看到的,BouncyCastle 可以与 JKS 一起使用
如何使用 BouncyCastle 阅读 JKS?
使用 BKS 代替 JKS
KeyStore keystore = KeyStore.getInstance("BKS", "BC");
请参阅 https://www.bouncycastle.org/specifications.html
的第 6.4 节 - 密钥库
The Bouncy Castle package has three implementation of a keystore.
The first "BKS" is a keystore that will work with the keytool in the same fashion as the Sun "JKS" keystore.
结果将与 Sun 提供商相同。如果您得到一个空列表,请检查 JKS 是否为空并且您正在正确阅读它
我有一个 Java KeyStore (JKS),我需要用 BouncyCastle 读取它。
我已将 BC
个提供商添加到提供商列表的顶部:
Security.insertProviderAt(new BouncyCastleProvider(), 1);
如果我这样创建 KeyStore:
final KeyStore keystore = KeyStore.getInstance("JKS", "BC");
我收到一个错误:
java.security.KeyStoreException: JKS not found
如果我不指定提供商,KeyStore 将使用 Sun
提供商创建,keystore.aliases()
将包含 EmptyEnumeration
.
正如我在 this 主题中看到的,BouncyCastle 可以与 JKS 一起使用
如何使用 BouncyCastle 阅读 JKS?
使用 BKS 代替 JKS
KeyStore keystore = KeyStore.getInstance("BKS", "BC");
请参阅 https://www.bouncycastle.org/specifications.html
的第 6.4 节 - 密钥库The Bouncy Castle package has three implementation of a keystore. The first "BKS" is a keystore that will work with the keytool in the same fashion as the Sun "JKS" keystore.
结果将与 Sun 提供商相同。如果您得到一个空列表,请检查 JKS 是否为空并且您正在正确阅读它