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