密钥库的错误版本 - 使用BouncyCastle的V146生成的BKS

时间:2013-05-31 11:01:53

标签: java android ssl-certificate keystore keytool

我正在尝试在Android应用程序中使用BKS密钥库,但我不断收到此异常。

05-31 19:53:52.963: E/AndroidRuntime(18992): FATAL EXCEPTION: AsyncTask #2
05-31 19:53:52.963: E/AndroidRuntime(18992): java.lang.RuntimeException: An error occured while executing doInBackground()
05-31 19:53:52.963: E/AndroidRuntime(18992):    at android.os.AsyncTask$3.done(AsyncTask.java:278)
05-31 19:53:52.963: E/AndroidRuntime(18992):    at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
05-31 19:53:52.963: E/AndroidRuntime(18992):    at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
05-31 19:53:52.963: E/AndroidRuntime(18992):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
05-31 19:53:52.963: E/AndroidRuntime(18992):    at java.util.concurrent.FutureTask.run(FutureTask.java:137)
05-31 19:53:52.963: E/AndroidRuntime(18992):    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
05-31 19:53:52.963: E/AndroidRuntime(18992):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
05-31 19:53:52.963: E/AndroidRuntime(18992):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
05-31 19:53:52.963: E/AndroidRuntime(18992):    at java.lang.Thread.run(Thread.java:856)
05-31 19:53:52.963: E/AndroidRuntime(18992): Caused by: java.lang.RuntimeException: java.io.IOException: Wrong version of key store.
05-31 19:53:52.963: E/AndroidRuntime(18992):    at org.nick.customcert.https.MainActivity.loadTrustStore(MainActivity.java:691)
05-31 19:53:52.963: E/AndroidRuntime(18992):    at org.nick.customcert.https.MainActivity.access$4(MainActivity.java:677)
05-31 19:53:52.963: E/AndroidRuntime(18992):    at org.nick.customcert.https.MainActivity$2.manipulate(MainActivity.java:273)
05-31 19:53:52.963: E/AndroidRuntime(18992):    at org.nick.customcert.https.MainActivity$ManipulateTrustStoreTask.doInBackground(MainActivity.java:224)
05-31 19:53:52.963: E/AndroidRuntime(18992):    at org.nick.customcert.https.MainActivity$ManipulateTrustStoreTask.doInBackground(MainActivity.java:1)
05-31 19:53:52.963: E/AndroidRuntime(18992):    at android.os.AsyncTask$2.call(AsyncTask.java:264)
05-31 19:53:52.963: E/AndroidRuntime(18992):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
05-31 19:53:52.963: E/AndroidRuntime(18992):    ... 5 more
05-31 19:53:52.963: E/AndroidRuntime(18992): Caused by: java.io.IOException: Wrong version of key store.
05-31 19:53:52.963: E/AndroidRuntime(18992):    at com.android.org.bouncycastle.jce.provider.JDKKeyStore.engineLoad(JDKKeyStore.java:812)
05-31 19:53:52.963: E/AndroidRuntime(18992):    at java.security.KeyStore.load(KeyStore.java:589)
05-31 19:53:52.963: E/AndroidRuntime(18992):    at org.nick.customcert.https.MainActivity.loadTrustStore(MainActivity.java:684)
05-31 19:53:52.963: E/AndroidRuntime(18992):    ... 11 more

我确实使用了BouncyCastle的1.46版来生成密钥库。我用keytool

测试了它
keytool -list -keystore truststore.bks -provider org.bouncycastle.jce.provider.BouncyCastleProvider -providerpath bcprov-jdk15on-146.jar -storetype BKS

我还在手机上打印了提供商:

05-31 19:53:52.918: D/MainActivity(18992): Version : BouncyCastle Security Provider v1.46 : BouncyCastle Security Provider v1.46

我不知道该怎么做......

1 个答案:

答案 0 :(得分:1)

在这里回答: Wrong version of keystore on android call

所需的证书版本取决于Android版本: Android 15-需要BKS-V1(旧版) Android 15 +需要BKS / BKS-V1(新版本) Android 23 +需要BKS(BKS-V1不支持)