通过cli运行时找不到AndroidKeyStore实现

时间:2017-11-22 06:48:43

标签: java android security android-studio android-keystore

我有一个使用Android Keystore API的java程序。我们正在运行这个prog(作为Java编程但不是android应用程序)在基于android的板上使用加密操作。

通过android studio运行这个程序工作正常,即创建一个示例应用程序(内部使用通过AndroidKeystore securitye Provider的密钥库API)并安装该apk。但是我们需要通过命令行运行这个程序,因为实际的程序不会是apk格式。

看起来安全提供程序AndroidKeyStore仅在使用应用程序时运行,但不能通过命令行运行。

尝试以下方式:

1)通过javac编译编程,创建jar然后转换为dex以通过cli运行

2)从android studio创建jar然后转换为dex以运行cli

3)Android应用程序正在模拟器和电路板上工作,

126|u0_a82@msm8916_64:/data/data/berserker.android.apps.sshdroid/home $ dalvikvm -cp apiclient.dex com.example.test_jar.ApiClientAndr>
in api client main
java.security.KeyStoreException: java.security.NoSuchAlgorithmException: KeyStore AndroidKeyStore implementation not found
    at java.security.KeyStore.getInstance(KeyStore.java:119)
    at com.example.test_jar.ApiClientAndroidKeyStore.main(ApiClientAndroidKeyStore.java:279)
Caused by: java.security.NoSuchAlgorithmException: KeyStore AndroidKeyStore implementation not found
    at org.apache.harmony.security.fortress.Engine.notFound(Engine.java:190)
    at org.apache.harmony.security.fortress.Engine.getInstance(Engine.java:139)
    at java.security.KeyStore.getInstance(KeyStore.java:116)
    ... 1 more

以下是安全提供商列表

1)在模拟器/电路板上运行时

Name: AndroidKeyStoreBCWorkaround, Information:Android KeyStore security provider to work around Bouncy Castle
Name: AndroidOpenSSL, Information: Android's OpenSSL-backed security provider
Name: BC, Information: BouncyCastle Security Provider v1.52
Name: Crypto, Information: HARMONY (SHA1 digest; SecureRandom; SHA1withDSA signature)
Name: HarmonyJSSE, Information: Harmony JSSE Provider
Name: AndroidKeyStore, Information:Android KeyStore security provider

2)通过cli

运行时
Name: AndroidOpenSSL, Information: Android's OpenSSL-backed security provider
Name: BC, Information: BouncyCastle Security Provider v1.52
Name: Crypto, Information: HARMONY (SHA1 digest; SecureRandom; SHA1withDSA signature)
Name: HarmonyJSSE, Information: Harmony JSSE Provider

0 个答案:

没有答案