简体   繁体   English

找不到带有keytool的SunPKCS11提供程序

[英]SunPKCS11 provider not found with keytool

I am running the following command with java 9 : 我正在使用Java 9运行以下命令:

 keytool -keystore NONE -storetype PKCS11 -providerClass sun.security.pkcs11.SunPKCS11 -providerArg pkcs11conf -list 

and get the flowing error : 并得到流动的错误:

keytool error: java.lang.Exception: Provider "sun.security.pkcs11.SunPKCS11" not found keytool错误:java.lang.Exception:找不到提供程序“ sun.security.pkcs11.SunPKCS11”

In Java 8 it works. 在Java 8中有效。

How does one use keytool with SunPKCS11 provider? 一个如何与SunPKCS11提供程序一起使用keytool?

The problem was with my pkcs11conf file. 问题出在我的pkcs11conf文件中。 Java don't like the single backslash in my DLL path : Java不喜欢我的DLL路径中的单个反斜杠:

"C:\\Path\\to\\my\\pkcs11lib\\mypkcs11lib.dll" : Wrong “ C:\\ Path \\至\\ my \\ pkcs11lib \\ mypkcs11lib.dll”:错误

"C:\\\\Path\\\\to\\my\\\\pkcs11lib\\\\mypkcs11lib.dll" : OK “ C:\\\\ Path \\\\到\\ my \\\\ pkcs11lib \\\\ mypkcs11lib.dll”:确定

The different between Java 8 and Java 9 is the error message. Java 8和Java 9之间的区别是错误消息。

Java 9 : Java 9:

keytool error: java.lang.Exception: Provider "sun.security.pkcs11.SunPKCS11" not found

Java 8 : Java 8:

keytool error: java.lang.reflect.InvocationTargetException

I realized that when I added -v to the command. 我意识到,当我在命令中添加-v时。

Java 9 : Java 9:

java.lang.Exception: Provider "sun.security.pkcs11.SunPKCS11" not found
        at java.base/sun.security.tools.keytool.Main.doCommands(Main.java:798)
        at java.base/sun.security.tools.keytool.Main.run(Main.java:397)
        at java.base/sun.security.tools.keytool.Main.main(Main.java:390)
Caused by: sun.security.pkcs11.ConfigurationException: Absolute path required for library value: xxx.dll
        at jdk.crypto.cryptoki/sun.security.pkcs11.Config.parseLibrary(Config.java:682)
        at jdk.crypto.cryptoki/sun.security.pkcs11.Config.parse(Config.java:392)
        at jdk.crypto.cryptoki/sun.security.pkcs11.Config.<init>(Config.java:210)
        at jdk.crypto.cryptoki/sun.security.pkcs11.SunPKCS11$1.run(SunPKCS11.java:113)
        at jdk.crypto.cryptoki/sun.security.pkcs11.SunPKCS11$1.run(SunPKCS11.java:110)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at jdk.crypto.cryptoki/sun.security.pkcs11.SunPKCS11.configure(SunPKCS11.java:110)
        at java.base/sun.security.tools.KeyStoreUtil.loadProviderByName(KeyStoreUtil.java:285)
        at java.base/sun.security.tools.KeyStoreUtil.loadProviderByClass(KeyStoreUtil.java:309)
        at java.base/sun.security.tools.keytool.Main.doCommands(Main.java:788)
        ... 2 more

Java 8: Java 8:

java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
        at java.lang.reflect.Constructor.newInstance(Unknown Source)
        at sun.security.tools.keytool.Main.doCommands(Unknown Source)
        at sun.security.tools.keytool.Main.run(Unknown Source)
        at sun.security.tools.keytool.Main.main(Unknown Source)
Caused by: java.security.ProviderException: Error parsing configuration
        at sun.security.pkcs11.Config.getConfig(Config.java:88)
        at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.java:129)
        at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.java:103)
        ... 7 more
Caused by: sun.security.pkcs11.ConfigurationException: Absolute path required for library value: xxx.dll
        at sun.security.pkcs11.Config.parseLibrary(Config.java:690)
        at sun.security.pkcs11.Config.parse(Config.java:398)
        at sun.security.pkcs11.Config.<init>(Config.java:220)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM