Re: [Jsdsi-users] KeyStore
Status: Pre-Alpha
Brought to you by:
sajma
From: Sameer A. <aj...@gm...> - 2004-08-11 12:15:31
|
Dav, My guess is that the KeyStore is attempting to unmarshal the public key and can't find the code to do it. Make sure the JSDSI Provider is loaded when you load from the KeyStore. If that doesn't fix it, you might look through the KeyStore docs to determine hwo to register new key types with it. Its possible we need to provide a new class to make this work. Sameer On Tue, 10 Aug 2004 21:59:38 -0700, Dav Coleman <dav...@gm...> wrote: > Hi, > > I'm trying to save a Private Key and Certificate to a KeyStore and > then load it back. I'm able to create the keystore on the file system > without throwing any exceptions, but when I try to load it I get > > java.security.cert.CertificateException: SPKI not found > at java.security.cert.CertificateFactory.getInstance(CertificateFactory.java:191) > at sun.security.provider.JavaKeyStore.engineLoad(JavaKeyStore.java:670) > at java.security.KeyStore.load(KeyStore.java:652) > at com.s0ciety.demo.CLI.loadKeyStore(CLI.java:129) > > Any ideas on what would cause that? > > Here is the (I hope) relevant code snippets > > create and save keystore: > > pair = jsdsi.RSAPublicKey.create(); > java.security.PrivateKey privKey = pair.getPrivate(); > java.security.PublicKey pubKey = pair.getPublic(); > > jsdsi.RSAPublicKey jsdsiPubKey = (jsdsi.RSAPublicKey)pair.getPublic(); > Date expire = new Date(now.getTime() + (86400 * 30)); > jsdsi.Validity validity = new jsdsi.Validity(now, expire); > jsdsi.Cert cert = new jsdsi.NameCert(jsdsiPubKey, jsdsiPubKey, > validity, "display hint", "blah... comment field", "my jsdsi pubkey"); > jsdsi.Hash hash = new jsdsi.Hash("MD5", cert.toByteArray()); > jsdsi.Signature signature = null; > jsdsi.Principal principal = (jsdsi.Principal) pair.getPublic(); > signature = jsdsi.Signature.create(pair, cert, "MD5withRSA"); > jsdsi.Certificate certificate = new jsdsi.Certificate(cert, signature); > jsdsi.Certificate[] certificate_chain = new jsdsi.Certificate[] > { certificate }; > // Create an empty keystore object > keystore = KeyStore.getInstance(KeyStore.getDefaultType()); > keystore.load(null, password.toCharArray()); // null input > stream to create empty keystore > keystore.setKeyEntry("myalias", privKey, password.toCharArray(), > certificate_chain); > // Save the new keystore contents > FileOutputStream out = new FileOutputStream(keystoreFile); > keystore.store(out, password.toCharArray()); > out.close(); > > load keystore: > > FileInputStream fis = new FileInputStream(file); > keystore = KeyStore.getInstance(KeyStore.getDefaultType()); > keystore.load(fis, password.toCharArray()); > fis.close(); > System.out.println("- keystore loaded"); > System.out.println("- contains "+keyStore.size()+" entries"); > > Are there any code examples available for integrating JSDSI into an > application? I've read a lot of docs and published papers online and I > think I have a basic understanding of SPKI/SDSI capabilities, but I'm > completely new to PKI application development so I feel a little lost. > > -- > Dav Coleman > http://AkuAku.org/ > > ------------------------------------------------------- > SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media > 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 > Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift. > http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285 > _______________________________________________ > Jsdsi-users mailing list > Jsd...@li... > https://lists.sourceforge.net/lists/listinfo/jsdsi-users > > -- Sameer Ajmani http://ajmani.net |