Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error on class sun.security.pkcs11.SunPKCS11

Tags:

java

keystore

I have made keyStore in java1.4 using this code.

 `public static void main(String[] args )
      throws IOException, DocumentException, GeneralSecurityException {
String pkcs11Config = "name=eToken\nlibrary=C://WINDOWS//system32//eTPKCS11.dll";
java.io.ByteArrayInputStream pkcs11ConfigStream = new java.io.ByteArrayInputStream(pkcs11Config.getBytes());
sun.security.pkcs11.SunPKCS11 providerPKCS11 = new   sun.security.pkcs11.SunPKCS11(pkcs11ConfigStream);
java.security.Security.addProvider(providerPKCS11);

// Get provider KeyStore and login with PIN
String pin = "123456";
 java.security.KeyStore keyStore =java.security.KeyStore.getInstance("PKCS11", providerPKCS11);
keyStore.load(null, pin.toCharArray());

// Enumerate items (certificates and private keys) in the KeyStore
java.util.Enumeration<String> aliases = keyStore.aliases();
String alias=null;
while (aliases.hasMoreElements()) {
 alias = aliases.nextElement();
System.out.println(alias);

 }}    

But I have get an error

`Error(2,28): cannot access class sun.security.pkcs11.SunPKCS11; class file has wrong version 49.0, should be 45.3 or 46.0 or 47.0 or 48.0`

Please Tell me the solution. How can I download the class of version below 49 like 48 etc.

like image 362
aich.pom Avatar asked Nov 28 '25 11:11

aich.pom


1 Answers

SunPKCS11 was introduced in Java 1.5

You must either upgrade the Java version or remain unable to utilize it.

Uplifting a project isn't uncommon. "The project is already running" isn't a reason to avoid this, as it's an expected part of a continuous development process.

like image 99
Vivek Chavda Avatar answered Nov 30 '25 01:11

Vivek Chavda