• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Error when encrypting data using Cipher

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have a problem that I'm hoping someone may be able to help me with.

I want to load a public key (.cer file) into a keystore and then use this key to encrypt some data.

The key appears to be loaded into the keystore correctly because I can view its contents using the keystore.getCertificate(alias) method.

However, when I then attempt to use this key to encrypt a piece of data, I get the following error displayed:

Exception in thread "main" java.security.InvalidKeyException: Unsupported key type: null
at sun.security.mscapi.RSACipher.engineGetKeySize(RSACipher.java:404)


Here is my code:



I am not sure why I am getting this error therefore if someone could provide some input or guidance with this matter then that would be greatly appreciated.

Regards
 
Roses are red, violets are blue. Some poems rhyme and some don't. And some poems are a tiny ad.
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic