Operating System - HP-UX
1751816 Members
5854 Online
108781 Solutions
New Discussion

Getting error - java.security.InvalidKeyException: Private Key cannot be used to encrypt.

 
pruthig
New Member

Getting error - java.security.InvalidKeyException: Private Key cannot be used to encrypt.

Hi 

I am getting below error while I try to encrypt using RSA key on HPUX platform

java.security.InvalidKeyException: Private Key cannot be used to encrypt.

I didn't face any issue on Linux and Windows with Oracle JDK installed. Can anybody please suggest workaround for this issue. Code is legacy and I can't change existing functionality.

1 REPLY 1
Steven Schweda
Honored Contributor

Re: Getting error - java.security.InvalidKeyException: Private Key cannot be used to encry

> I am getting below error while I try to encrypt using RSA key [...]

   "try to encrypt" what, _how_, exactly?  As usual, showing actual
commands (or program statements) with their actual output can be more
helpful than vague descriptions ("try to encrypt") or interpretations.

> [...] on HPUX platform

   uname -a

> java.security.InvalidKeyException: Private Key cannot be used to encrypt.

   Java version?

   I know nothing, but that message suggests (to me) that you've
specified a private key where you should have specified a public key.

> I didn't face any issue on Linux and Windows with Oracle JDK
> installed. [...]

   I can't see what you did on those systems, either.

> Can anybody please suggest workaround for this issue. [...]

   Knowing nothing, I might try a Web search for, say:

      "java.security.InvalidKeyException: Private Key cannot be used to encrypt."

 

   The Java motto: Write Once, Debug Everywhere.