[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

AW: [iaik-jce] Need help putting my private key in a keystore



Hallo,

a short sample (look at
http://java.sun.com/products/jdk/1.2/docs/guide/security/CryptoSpec.html)
for more information):


         KeyStore keyStore = KeyStore.getInstance(keyStoreName, provider);
         keyStore.load(null, null);

         System.out.println("Store private key + cert chain...");
         keyStore.setKeyEntry("myEntry", privateKey, password, certs);

         System.out.println("Save keystore to file ...");
         FileOutputStream os = new FileOutputStream("...");
         keyStore.store(os, password);
         os.close();

          FileInputStream is = new FileInputStream("...");
         KeyStore keyStore1 = KeyStore.getInstance(keyStoreName, provider);
         keyStore1.load(is, password);
         is.close();



         // get key
         System.out.println("Fetching key...");
         try {
            Key key = keyStore1.getKey("myEntry", password);
            if (key != null) {
               System.out.println("Got key: " + key);
            } else {
               System.out.println("Missing key!");
            }
         } catch (UnrecoverableKeyException ex) {
            System.out.println("Error in getting key: " + ex.getMessage());
         }


         // get certificates
         System.out.println("Fetching certificates...");

         Certificate[] chain = keyStore1.getCertificateChain("myEntry");

         ...


         // clear password
         for (int i = 0; i < password.length; i++)
           password[i] = (char)0;


Dieter Bratko

-----Ursprüngliche Nachricht-----
Von: iaik-jce-owner@iaik.tu-graz.ac.at
[mailto:iaik-jce-owner@iaik.tu-graz.ac.at]Im Auftrag von Gert Verheyen
Gesendet: Donnerstag, 27. Juli 2000 15:16
An: 'iaik-jce@iaik.at'
Betreff: [iaik-jce] Need help putting my private key in a keystore


I have a problem with putting my private key that I obtained from a .pfx
file in a keystore.
When I want to add the keyentry to the keystore the following Exception is
thrown:
java.security.UnrecoverableKeyException: Private key not stored as PKCS #8
EncryptedPrivateKeyInfo

Is there anyone who has ever done this succesfully, a little example program
would help a lot.  Thanks


--
Mailinglist-archive at
http://jcewww.iaik.at/mailarchive/iaik-jce/jcethreads.html

To unsubscribe send an email to listserv@iaik.at with the folowing content:
UNSUBSCRIBE iaik-jce




smime.p7s