Java.security.Keystore aliases on JDK 1.6 vs IBM 1.5

I have a problem with the return value of the KeyStore.aliases () enumeration;

FileInputStream is = new FileInputStream("/tmp/file.p12"); List<String> aliases = new ArrayList<String>(); KeyStore keystore = KeyStore.getInstance("PKCS12"); keystore.load(is, password.toCharArray()); is.close(); Enumeration<String> e=keystore.aliases(); while(e.hasMoreElements()) { // never reaches here because "e" is empty System.out.println(e.nextElement().toString()); i++; } 

C Java Version "1.6.0_22" Java (TM) SE Runtime Environment (Build 1.6.0_22-b04) Java HotSpot (TM) 64-bit Server VM (Build 17.1-b03, Mixed Mode)

I get an empty counter

With java version "1.5.0" Java (TM) 2 Runtime Environment, standard version (build pxi32devifx-20100511a (SR11 FP2)) IBM J9 VM (build 2.3, J2RE 1.5.0 IBM J9 2.3 Linux x86-32 j9vmxi3223ifx-20100510 (JIT enabled) J9VM - 20100509_57823_lHdSMr JIT - 20091016_1845ifx7_r8 GC - 20091026_AA) JCL - 20100511a

I can get all the aliases.

How can I get all store pkcs12 aliases using Sun / Oracle JDK6?

thanks

+4
source share
2 answers

There seems to be something wrong with the code, and I would have thought that PKCS # 12 key stores should be readable in all versions of all JREs.

Have you tried using OpenSSL to validate your store?

0
source

here's the answer:

http://www-01.ibm.com/support/docview.wss?uid=swg1IZ77005

- Conclusion of the problem. This defect will be reported in:
1.4.2 SR14
5.0.0 SR12
6.0.0 SR9

The PKCS SafeContents.getSafeBags( ) method has been modified to detect when the SafeBag array is null and instead returns an empty SafeBag array. PKCS callers of this method are ready to process an empty SafeBag array.

0
source

All Articles