Android的充气城堡:IOException异常 [英] Android bouncy castle: IOException

查看:243
本文介绍了Android的充气城堡:IOException异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用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 an instance 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());

我尝试过各种版本的<一个下载的充气城堡的JAR href="http://www.bouncycastle.org/latest_releases.html">http://www.bouncycastle.org/latest_releases.html

我是什么做错了吗?

谢谢, 兰吉特

推荐答案

这似乎试图打开密钥库时BouncyCastle的版本附带的Andr​​oid 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异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆