Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to load a pkcs12 file in to KeyStore object?

Posted on 2008-06-12
4
Medium Priority
?
1,606 Views
Last Modified: 2013-12-22
I'm not able to extract my private key from pkcs12 file which was loaded in to KeyStore object .

ksp = KeyStore.getInstance("PKCS12");
            fis = new FileInputStream(policyFile);
            ksp.load(fis, null);
      System.out.println("size of the ksp::"+ksp.size());//---- return 0
 
            char[] privateKeyPassword = access_policy.toCharArray();
            
            PrivateKey key = (PrivateKey) ksp.getKey("XXXXX"
                    + access_policy.toLowerCase(), privateKeyPassword);
            Signature s = Signature.getInstance("SHA1withRSA");
            s.initSign(key);

Open in new window

0
Comment
Question by:vpram86
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 9

Accepted Solution

by:
mbodewes earned 500 total points
ID: 21771455
Have you tried filling in the password in the load() method instead? PKCS#12 is a password encrypted file, so I am wondering if just supplying the password for the key alias works (my guess is not, please reply if this doesn't work, I'll look for my PKCS#12 code at work).
0
 
LVL 9

Expert Comment

by:mbodewes
ID: 21912627
Hello?
0

Featured Post

When ransomware hits your clients, what do you do?

MSPs: Endpoint security isn’t enough to prevent ransomware.
As the impact and severity of crypto ransomware attacks has grown, Webroot has fought back, not just by building a next-gen endpoint solution capable of preventing ransomware attacks but also by being a thought leader.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Check out what's been happening in the Experts Exchange community.
What we learned in Webroot's webinar on multi-vector protection.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question