如何在黑莓P12文件实例x509证书 [英] How to instantiate X509Certificate from a P12 file in Blackberry

查看:292
本文介绍了如何在黑莓P12文件实例x509证书的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个有效的P12文件。我需要实例化一个X509Certificate对象,这样我就可以使用它作为一个客户端证书。

I have a valid P12 file. I need to instantiate an X509certificate object, so that I can use it as a client side certificate.

我知道已经有类似的问题回答这里,<一个href=\"http://stackoverflow.com/questions/4030585/how-to-instantiate-javax-security-x509certficate-object-from-a-p12-certificate\">How从P12证书实例javax.security.X509Certficate对象(含证书+私钥)

I realize that there is already a similar question answered here, How to instantiate javax.security.X509Certficate object from a p12 certificate (contains certificate + private key)

但在黑莓中的getInstance(String)方法不适用于密钥库。它可用于DeviceKeyStore和TrustedKeyStore。但是,我们可以在PKCS12参数不传递给getInstance()方法。

But in Blackberry, the getInstance(String) method is not available for KeyStore. It's available for DeviceKeyStore and TrustedKeyStore. But we can't pass the "PKCS12" parameter to the getInstance() method.

此外DeviceKeyStore或TrustedKeyStore没有负荷方法。他们有方法。但我不知道我们如何能的FileInputStream参数传递到一个。

Also DeviceKeyStore or TrustedKeyStore don't have the load methods. They have the set methods. But I'm not sure how we can pass fileinputstream parameter to that one.

有没有人试过这种?你知道什么其他方法可用于此?

Has anyone tried this? Do you know what alternate methods are available for this?

感谢您的帮助。

编辑:
有这样做的PEM文件的方法,(<一href=\"http://stackoverflow.com/questions/9132234/install-ssl-certificate-with-blackberry-app\">Install SSL证书与黑莓应用程序),这是我用最初尝试,使其工作。但格式不同。 PEM是一个Base64格式,它仅包含证书。

There is a method for doing this for PEM file,(Install SSL Certificate with BlackBerry App) which is what I used initially to try to make it work. But the formats differ. PEM is a Base64 format, and it contains just the certificate.

推荐答案

您可以这样做,调用外部应用程序。有一个部分解决方案:
<一href=\"http://supportforums.blackberry.com/t5/Java-Development/Handling-a-p12-certificate-store/td-p/654127\" rel=\"nofollow\">http://supportforums.blackberry.com/t5/Java-Development/Handling-a-p12-certificate-store/td-p/654127

You can invoke an external application for doing that. There is a partial solution: http://supportforums.blackberry.com/t5/Java-Development/Handling-a-p12-certificate-store/td-p/654127

但出于某种原因你没有得到进口的菜单!这件作品code的:

But for some reason you don't get the import menu! The piece of code:

Invocation certInvocation = new Invocation( "path to .p12 on SD Card");
certInvocation.setResponseRequired( false );
certInvocation.setID( BlackBerryContentHandler.ID_MEDIA_CONTENT_HANDLER );
certInvocation.setAction( ContentHandler.ACTION_OPEN );
certInvocation.setType( "application/x-pkcs12" );

Registry registry = Registry.getRegistry( Application.class.getName() );
try {

    registry.invoke( certInvocation );
}
catch (Throwable t) {}

这篇关于如何在黑莓P12文件实例x509证书的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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