使用keytool找不到SunPKCS11提供程序

时间:2017-11-21 12:06:35

标签: java keytool java-9 pkcs#11 java-security

我正在使用java 9运行以下命令:

add_filter( 'template_include', 'use_archive_dog', 99 );
function use_archive_dog( $template ) {

    if ( is_post_type_archive('dog')  ) {
        $new_template = locate_template( array( 'archive-dog.php' ) );
        if ( '' != $new_template ) {
            return $new_template ;
        }
    }

    return $template;
}

并得到流动的错误:

  

keytool错误:java.lang.Exception:Provider   "删除sun.security.pkcs11.SunPKCS11"找不到

在Java 8中它可以工作。

如何将keytool与SunPKCS11提供商一起使用?

1 个答案:

答案 0 :(得分:0)

问题在于我的pkcs11conf文件。 Java不喜欢我的DLL路径中的单个反斜杠:

  

" C:\路径\到\我\ pkcs11lib \ mypkcs11lib.dll" :错了

     

" C:\\路径\\到\我\\ pkcs11lib \\ mypkcs11lib.dll" :好的

Java 8和Java 9之间的差异是错误消息。

Java 9:

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

Java 8:

keytool error: java.lang.reflect.InvocationTargetException

我意识到当我将 -v 添加到命令时。

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.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)