Solved

How to load a pkcs12 file in to KeyStore object?

Posted on 2008-06-12
4
1,591 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
4 Comments
 
LVL 9

Accepted Solution

by:
mbodewes earned 125 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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

On Beyond Tools A conversation I recently had with the DevOps manager of a major online retailer really made me think about DevOps monitoring tools (https://www.onpage.com/devops-incident-management-tool/). The manager and I discussed how sever…
Each year, investment in cloud platforms grows more than 20% (https://www.immun.io/hubfs/Immunio_2016/Content/Marketing/Cloud-Security-Report-2016.pdf?submissionGuid=a8d80a00-6fee-4b85-81db-a4e28f681762) as an increasing number of companies begin to…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn how to implement Singleton Design Pattern in Java.

831 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