[Jsdsi-users] KeyStore
Status: Pre-Alpha
Brought to you by:
sajma
From: Dav C. <dav...@gm...> - 2004-08-11 04:59:40
|
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/ |