Merlijn Sebrechts
Merlijn Sebrechts

Reputation: 633

keytool error: java.io.IOException: DER input, Integer tag error

I'm trying to convert a private key in a Java Keystore into PEM Format. This answer explains that the first step is to convert the keystore into PKCS12 format using the keytool command.

However, I get the following error:

$ keytool -importkeystore -srckeystore client.keystore.jks -destkeystore client1.p12 -srcstoretype JKS -deststoretype PKCS12 -srcalias client1 -destalias client1
...
keytool error: java.io.IOException: DER input, Integer tag error

Searching for this error online tells me that this has to do with encryption. I know the source keystore is encrypted, but supplying the passwords in the command gives the exact same error. How can I export the private key?

Upvotes: 3

Views: 15234

Answers (1)

Merlijn Sebrechts
Merlijn Sebrechts

Reputation: 633

The issue turned out to be the destination keystore, not the source one. The file client1.p12 already existed but it was in an incompatible format.

The solution was to remove the file client1.p12 and run the keytool command again.

Upvotes: 1

Related Questions