gpt4 book ai didi

java - sun.security.pkcs11.SunPKCS11 类上的错误

转载 作者:行者123 更新时间:2023-11-30 07:58:05 25 4
gpt4 key购买 nike

我使用此代码在java1.4中制作了keyStore。

 `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);

}}

但是我收到一个错误

`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`

请告诉我解决方案。如何下载49以下的版本,例如48等

最佳答案

SunPKCS11 是在 Java 1.5 中引入的

您必须升级 Java 版本,否则仍无法使用它。

提升项目并不罕见。 “项目已经运行”并不是避免这种情况的理由,因为它是持续开发过程的预期部分。

关于java - sun.security.pkcs11.SunPKCS11 类上的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32373022/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com