Android是否支持.jks密钥库类型? [英] Does android support .jks keystore type?
问题描述
我正在尝试使用服务器团队提供的密钥库连接到服务器.
I am trying to connect to server using keystore which is provided by server team.
在首先向服务器发送服务调用时,我使用以下api创建了KeyStore实例
While sending service call to server first i created KeyStore Instance by using following api
KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
它返回的密钥库类型为"BKS".
It’s returning the keystore type as "BKS".
服务器团队发送的密钥库的类型为".jks"(somename.jks).因此,我收到异常消息密钥库的版本错误".
The Keystore what server team sent is of type ".jks"(somename.jks) So, I am getting exception "Wrong version of key store".
我尝试通过以下方式将"JKS"传递给KeyStore的getInstance()
I tried by passing "JKS" to getInstance() of KeyStore by following way
KeyStore keystore = KeyStore.getInstance("JKS");
但是在这里,我得到了异常找不到KeyStore JKS实现".
But here I am getting exception "KeyStore JKS implementation not found".
这是一段代码:
KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
InputStream instream = mContext.getAssets().open("somename.jks");
try {
trustStore.load(instream, "password".toCharArray());
} finally {
try {
instream.close();
} catch(Exception ignore) {
}
}
请指导我解决此问题.
推荐答案
我认为Android仅支持BouncyCastle KeyStore(称为BKS)... 您仍然可以使用 Portecle
I think Android support 'only' BouncyCastle KeyStores (known as BKS)... You still can use Portecle
要将其从JKS转换为BKS,应像魅力一样工作(至少在尝试将.CRT存储为BKS格式时对我有用!)
To convert it from JKS to BKS, should work like a charm (at least it worked for me when trying to store my .CRT into a BKS format ! ;)
'only'的意思是,在这里很容易:p,否则您将不得不操纵东西
'only' meaning, easily here :p, else you'll have to manipulate stuffs
这篇关于Android是否支持.jks密钥库类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!