Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

" invalid encoding for signature" when following the Java Tutorial  RSS feed

Chris Lorenz
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am following the Java tutorial at:

It concerns programmatically extracting a private key from a keystore as well as the matching certificate on the sender side, then generating a signature with the private key and finally saving both cerificate and signature in a file each.
On the receiver's side the cerificate file is read in programmatically as well as the signature file, the public key is extracted from the certificate and finally used to programmatically verify the signature.

The tutorial doesn't print the full code for this. Instead, it merely prints some (plausible looking) snippets that the reader is supposed to use to modify the classes and that were provided in the preceding chapters of this lesson.

I followed these suggestions, modified both files to work in principle. I used the keystore and the keypair+certificate that was created while following the earlier part of this tutorial trail starting at

In short, I completely stayed within java tutorial material.
Still, when running my new and enhanced class after running my new and enhanced class I get the above mentioned " invalid encoding for signature" .

What am I missing?
Can anyone provide concrete code alterations to make it work?
As you can see, I hard coded some necessary infos into the code. Removing them will be my next step after the main problem is solved.
Thank you!

The code for both classes is as follows:


  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!