How to instantiate X509Certificate from a P12 file in Blackberry

拟墨画扇 提交于 2019-12-08 05:20:40

问题


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

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)

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.

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?

Thanks for your help.

Edit: 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.


回答1:


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

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) {}


来源:https://stackoverflow.com/questions/13151134/how-to-instantiate-x509certificate-from-a-p12-file-in-blackberry

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!