Path: csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!news.glorb.com!news-out.readnews.com!news-xxxfer.readnews.com!news-out.news.tds.net!newsreading01.news.tds.net!86597e80!not-for-mail From: "Dave Miller" Subject: Re: Loading keystores fro Message-ID: X-Comment-To: comp.lang.java.security Newsgroups: comp.lang.java.security In-Reply-To: <5bea81f5-d7db-4990-86ea-00b74857dbda@p25g2000hsf.googlegroups.com> References: <5bea81f5-d7db-4990-86ea-00b74857dbda@p25g2000hsf.googlegroups.com> Content-Type: text/plain; charset=IBM437 Content-Transfer-Encoding: 8bit X-Gateway: time.synchro.net [Synchronet 3.15a-Win32 NewsLink 1.92] Lines: 49 Date: Wed, 27 Apr 2011 16:08:24 GMT NNTP-Posting-Host: 96.60.20.240 X-Complaints-To: news@tds.net X-Trace: newsreading01.news.tds.net 1303920504 96.60.20.240 (Wed, 27 Apr 2011 11:08:24 CDT) NNTP-Posting-Date: Wed, 27 Apr 2011 11:08:24 CDT Organization: TDS.net Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.security:144 To: comp.lang.java.security Thomaspantalacci311@hotmail.com wrote: > I had an other question, but i couldn't found any response. I have two > certificates in my smartcard. How can i load the both certificates. > I tryed this code > > char[] pin = smartCardPIN.toCharArray(); > KeyStore keyStore = null; > try{ > keyStore = KeyStore.getInstance("PKCS11");// > }catch(Exception e){ > e.printStackTrace(); > } > keyStore.load(null, pin); > Enumeration aliases = keyStore.aliases(); > if (aliases.hasMoreElements()) { > String alias = (String)aliases.nextElement(); > System.out.println("alias:"+alias); > //getting the certificate chain and the private key > Certificate[] certificationChain = > keyStore.getCertificateChain(alias); > PrivateKey privateKey = (PrivateKey) keyStore.getKey(alias, > null); > .... > > } > > ... > > > But aliases enumeration has only one element, since it prints You've created a keystore and placed one element into it. When you say "show me elements" it... shows you the one that you've entered. I've never tried to manipulate the keystore on the client's machine so I won't be any help there. My sense is that doing so would take a bit of a hack (or crack). As the keystore holds the keys (literally) to the client's security, the JVM probably tries to keep it pretty well locked up. -- Dave Miller Java Web Hosting at: http://www.cheap-jsp-hosting.com/ --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24