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

[iaik-jce] No private key when importing PKCS file into IIS



Hi!

The subject says it all really. I have created an RSA private key
and have received a certificate.

I import these (to create a keystore) and then create a PKCS12 object
that I then save to a file.

I then import this file into Windows2000 using the certificate manager and
everthing works OK. The problem is that the private key is no longer
attached to the certificate and is therefore useless to IIS.

Is there something I'm doing wrong here. Here is the code that
exports the PKCS12 object:

                CertificateBag[] certBags = new CertificateBag[chain.length];

                 byte[] keyId = new byte[] {0x01, 0x02, 0x03, 0x04};
                 KeyBag keyBag = new KeyBag(privateKey, "Joe Bloggs", keyId);

                 certBags[0] = new CertificateBag(chain[0]);
                 certBags[0].setFriendlyName("Joe Bloggs");
                 certBags[0].setLocalKeyID(keyId);

                 PKCS12 test_write = new PKCS12(new KeyBag(privateKey), 
certBags, true);
                 test_write.encrypt(KS_PASSWORD);

                 System.out.println(test_write.toString());

                 OutputStream os;
                 os = new FileOutputStream(KEYSTORE_DEFAULT_DIR + 
"/cert_export.pfx");
                 test_write.writeTo(os);
                 os.close();

Cheers,
/Trevor

_________________________________________________
Relate AB, Tegnérgatan 3, S-111 40 Stockholm
Tel: +46 (8) 454 18 80
Mobile: +46 (709) 679 250
mailto:trevor@relate.se
_________________________________________________
Framtidens IT-konsulter - Morgondagens lösningar!

--
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