Skip to Main Content

Java Security

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

jdk1.5.0 - problem when signing with a smartcard

843810Nov 18 2004 — edited Aug 29 2009
Hi,

I'm trying to make a signature with a smartcard.
The PKCS11 login succeed and I can retrieve information from the token (certificate, keys..).

However when following lines are executed, an exception is thrown:
Signature rsasig = Signature.getInstance("SHA1withRSA");
rsasig.initSign(privKey);
The exception is:

java.security.InvalidKeyException: Private keys must be instance of RSAPrivate(Crt)Key or have PKCS#8 encoding
at sun.security.rsa.RSAKeyFactory.translatePrivateKey(RSAKeyFactory.java:246)
at sun.security.rsa.RSAKeyFactory.engineTranslateKey(RSAKeyFactory.java:149)
at sun.security.rsa.RSAKeyFactory.toRSAKey(RSAKeyFactory.java:79)
at sun.security.rsa.RSASignature.engineInitSign(RSASignature.java:90)
at sun.security.rsa.RSASignature.engineInitSign(RSASignature.java:84)
at java.security.Signature$Delegate.init(Signature.java:1076)
at java.security.Signature$Delegate.chooseProvider(Signature.java:1036)
at java.security.Signature$Delegate.engineInitSign(Signature.java:1100)
at java.security.Signature.initSign(Signature.java:485)


I really need some help please!
I don't know if the problem is due to the configuration, the code or something else.. I can give you more details if needed!

The native layer is PKCS#11 v2.01.. perhaps too old? ( PKCS#11 v2.01 - Gemplus Cryptoki: gclib.dll - V 30004.01.003 - 08/04/2002)

Any idea?
thanks in advance

Loic
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 26 2009
Added on Nov 18 2004
16 comments
1,906 views