Improve company productivity with a Business Account.Sign Up

x
?
Solved

How to load a pkcs12 file in to KeyStore object?

Posted on 2008-06-12
4
Medium Priority
?
1,611 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
  • 2
2 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

Increase Security & Decrease Risk with NSPM Tools

Analyst firm, Enterprise Management Associates (EMA) reveals significant benefits to enterprises when using Network Security Policy Management (NSPM) solutions, while organizations without, experienced issues including non standard security policies and failed cloud migrations

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Feeling responsible for an unfortunate ransomware infection on my parent's network, persistence paid off as I was able to decrypt a strain of ransomware that was not previously (or at least publicly) cracked. I hope this helps others out there affec…
It has been a full year since one of the worst ransomware attacks we have seen, the Wannacry attack last year. The attacks have changed.  The way we are addressing them has also changed, but maybe not enough.
The viewer will learn how to implement Singleton Design Pattern in Java.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

588 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