问题描述
我使用Sun的keytool创建一个充气城堡密钥库和证书导入到它。该密钥工具确实产生了充气城堡格式的密钥存储。
I am using Sun's keytool to create a Bouncy castle keystore and import a certificate into it. The keytool does produce a keystore in the Bouncy castle format.
然后我尝试导入充气城堡密钥存储到一个Android程序。我能得到一个例如在BKS密钥库,但在密钥库调用加载抛出
I then attempt to import the Bouncy castle keystore into an Android program. I am able to get aninstance of the "BKS" keystore but calling load on the keystore throws
"java.io.IOException: Wrong version of key store".
这是在code
KeyStore keyStore = KeyStore.getInstance("BKS");
InputStream is = new FileInputStream("/mnt/sdcard/ArcGIS/mystore.bks");
keyStore.load(is, "abcdef".toCharArray());
我尝试过各种版本的http://www.bouncycastle.org/latest_releases.html
我是什么做错了吗?
谢谢,兰吉特
推荐答案
这似乎试图打开密钥库时BouncyCastle的版本附带的Android 4.0.3(API版本15)失败使用最新BouncyCastle的文库产生。版本错误键:当我使用 bcprov-jdk15on-147.jar
,我的样本Android应用程序失败,产生java.io.IOException创建密钥库店内
错误。
It seems the version of BouncyCastle shipped with Android 4.0.3 (API version 15) fails when trying to open keystores produced using the most recent BouncyCastle library. When I created a keystore using bcprov-jdk15on-147.jar
, my sample Android app failed with the java.io.IOException: Wrong version of key store
error.
但是,如果密钥库是与 bcprov-jdk16-146.jar
库创建的,那么它可能是由应用程序加载。我的解决方案是创建与此旧库密钥库。
However, if the keystore was created with the bcprov-jdk16-146.jar
library, then it could be loaded by the application. My solution was to create the keystore with this older library.
presumably这也将是对老年人的API版本的情况;在创建密钥库时尝试旧版本BouncyCastle的的。
Presumably this will also be the case for older API versions; try older versions of BouncyCastle when creating the keystore.
这篇关于Android的充气城堡:IOException异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!