• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

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
 
reply
    Bookmark Topic Watch Topic
  • New Topic