File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Other JSE/JEE APIs and the fly likes case of Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "case of "UnrecoverableKeyException: DER input, Integer tag error"?" Watch "case of "UnrecoverableKeyException: DER input, Integer tag error"?" New topic

case of "UnrecoverableKeyException: DER input, Integer tag error"?

Jon Dornback
Ranch Hand

Joined: Apr 24, 2002
Posts: 137
I have a keystore object that I added a public key to, as follows:
storage.setKeyEntry("mypublickey" ,pubkey,"pubkeypassword".toCharArray(), null);
I then try to pull the public key back out with this line:
pubkey = (PublicKey)storage.getKey("mypublickey","pubkeypassword".toCharArray());
but the call throws an exception: DER input, Integer tag error"
anyone know what causes this? i can get an enumeration of the aliases and list the key just fine, but cannot get it out of the keystore.

use the [CODE] tags - it makes it much easier for people to help you.
Jon Dornback
Ranch Hand

Joined: Apr 24, 2002
Posts: 137
after searching the net for hours, it turns out the problem is how the KeyStore is initialized. the java tutorial on the sun site says that the default provider should be fine, but it's not.

hope that saves someone some agony.
Iain Mcleod

Joined: Aug 24, 2003
Posts: 1

hope that saves someone some agony.

I can pass one further tip on for using keystores...
Don't try and create one manually the first time. It don't work!
I got this from somewhere else on the web - here is my function for creating keystores - it basically invokes the keystore tool and then picks up the output.
You may have to edit it a little...
Again, hope it helps someone, like Jon helped me :-)

(I edited the post to fix the typo involved in the code tags -- JAM)
[ August 25, 2003: Message edited by: Joel McNary ]
Joel McNary

Joined: Aug 20, 2001
Posts: 1815
Welcome to JavaRanch, Iain! We are glad that we could be of assistance, and thanks for the methods.

Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
jQuery in Action, 2nd edition
subject: case of "UnrecoverableKeyException: DER input, Integer tag error"?
Similar Threads
Storing Keys in KeyStore
InvalidKeyException: IOException : algid parse error, not a sequence
DER input, Integer tag error - with a pkcs12 keystore
getting error while creating keysotre
Managing the keystore through Code