Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Contributor
cr_az
Posts: 5
Registered: ‎08-17-2011
My Device: BB 9800

Load PFX (PKCS12) file as a KeyStore

Hi guys,

 

I`m trying to load a PFX file, but unfortunately, I can`t find any information how to do it. I`ve checked both Blackberry and Bouncy castle API.

 

Any suggestions?

 

Developer
simon_hain
Posts: 16,362
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Load PFX (PKCS12) file as a KeyStore

welcome to the support forums.

the search function offers some insight there. i know it would, as i posted about this problem myself :smileyhappy:

please read
http://supportforums.blackberry.com/t5/Java-Development/Handling-a-p12-certificate-store/m-p/654127#...
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
New Contributor
cr_az
Posts: 5
Registered: ‎08-17-2011
My Device: BB 9800

Re: Load PFX (PKCS12) file as a KeyStore

Hi Simon,

 

Thank you for reply, actually I read your topic.

You were discussed a way how to install PKCS12 file (add it to one of system keystores). My goal is to find a way how to load p12 file using some API and have an access to it`s fileds (private key, certificate) from my application.

Developer
simon_hain
Posts: 16,362
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Load PFX (PKCS12) file as a KeyStore

if the certificate is installed on the BB you can get more information about it using http://www.blackberry.com/developers/docs/6.0.0api/net/rim/device/api/crypto/keystore/KeyStore.html and http://www.blackberry.com/developers/docs/6.0.0api/net/rim/device/api/crypto/keystore/KeyStoreData.h...

the difficult part is installing the certificate.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
New Contributor
cr_az
Posts: 5
Registered: ‎08-17-2011
My Device: BB 9800

Re: Load PFX (PKCS12) file as a KeyStore

Hi simon_hain,

 

Class keyStore is usefull,  thank you for link, but the problem is that I have to know some information about PFX (subject)  - otherwise there is no way to find it in keystore.

 

Did you do it in your project? Could you please share some small example?

 

New Developer
digitalhuman
Posts: 13
Registered: ‎10-28-2008
My Device: Bol

Re: Load PFX (PKCS12) file as a KeyStore

[ Edited ]

Its so frustrating to see that PKCS12 is supported (http://btsc.webapps.blackberry.com/btsc/viewdocument.do?externalId=KB18586&sliceId=1&cmd=displayKC&d...

 

But none of the developers here on this forum is able to load a personal PFX and use its public and private key. Did anyone here manage to get it working? Else, i would KINDLY ask RIM to give us some more support cause im stuck at the same thing as everybody here.

Meet me at #SAMS: http://www.onsams.com, Twitter: @digital_human, or visit my blog: http://victorangelier.blogspot.com
Developer
simon_hain
Posts: 16,362
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Load PFX (PKCS12) file as a KeyStore

i was most successful with storing the certificate on the sdcard and invoking the certificate manager with it.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
New Developer
digitalhuman
Posts: 13
Registered: ‎10-28-2008
My Device: Bol

Re: Load PFX (PKCS12) file as a KeyStore

Hi Simon, Can you help me out with an example? I don't want to use the SDcard but maybe your example can get me back on track?

Meet me at #SAMS: http://www.onsams.com, Twitter: @digital_human, or visit my blog: http://victorangelier.blogspot.com
Developer
simon_hain
Posts: 16,362
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Load PFX (PKCS12) file as a KeyStore

I first try to open the certificate using the utility class:

 

byte[] certificateBytes = IOUtilities.streamToBytes(httpConnection.openInputStream());
Certificate certificate = CertificateUtilities.readCertificateFile(null, certificateBytes);
if (certificate == null) {

 if that fails i try invocation:

 

Invocation invocation = new Invocation(fileUri);
invocation.setAction(ContentHandler.ACTION_OPEN);
Registry registry = Registry.getRegistry(getClass().getName());
registry.invoke(invocation);

 

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter