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

[iaik-jce] Loading RSAPrivateKey from DER


I have a server certificate key in a DER encode file, here's a snipped of my
test application:

	ASN1 asn1= new ASN1(new FileInputStream("certs/key.der"));

	switch (asn1.getFormat()) {
		case ASN1.PEM:
			System.err.println("ANS1 Format : PEM");
		case ASN1.DER:
			System.err.println("ANS1 Format : DER");
			System.err.println("ANS1 Format : Huh?");

	RSAPrivateKey privateKey= new RSAPrivateKey(asn1.toASN1Object());

When I run this, I get :

	ANS1 Format : DER
	Unexpected error:
	java.security.InvalidKeyException: No PrivateKeyInfo:
	 No ASN.1 AlgorithmID type!
        	at iaik.pkcs.pkcs8.PrivateKeyInfo.a(Unknown Source)
        	at iaik.pkcs.pkcs8.PrivateKeyInfo.<init>(Unknown Source)
        	at Test.test(Test.java, Compiled Code)
        	at Test.main(Test.java:194)

For compatibility with our Weblogic instances, I have to load the private
key from a DER encoded file (so I can't use PKCS#12)

Any idea what I'm doing wrong?

David C. Harrison
+44 (0)20 7475 4393

Dresdner Kleinwort Wasserstein
20 Fenchurch Street
London EC3P 3DB
United Kingdom

If you have received this e-mail in error or wish to read our e-mail 
disclaimer statement and monitoring policy, please refer to 
http://www.drkw.com/disc/email/ or contact the sender.
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