简体   繁体   English

pkcs11异常解析配置:意外值Token ['(']

[英]pkcs11 exception parsing configuration: Unexpected value Token['(']

I know this is not a new problem (see https://bugs.openjdk.java.net/browse/JDK-8023745 ), but I was hoping someone would have a good workaround we could roll out. 我知道这不是一个新问题(请参阅https://bugs.openjdk.java.net/browse/JDK-8023745 ),但是我希望有人能够提供一个很好的解决方法,以便我们推出。

We are deploying an application, which is using pkcs11 and have encountered a problem with parsing config, which is located in "Program Files (x86)". 我们正在部署一个使用pkcs11的应用程序,并且在解析配置时遇到问题,该配置位于“程序文件(x86)”中。 What we're getting is: 我们得到的是:

sun.security.pkcs11.ConfigurationException: Unexpected value Token['('], line 2 sun.security.pkcs11.ConfigurationException:意外值Token ['('],第2行

In the dev environment, moving the location to a "clean" path solves the problem, so the issue is definitely the (x86). 在开发环境中,将位置移动到“干净”路径即可解决问题,因此问题肯定是(x86)。

What would be a good workaround, with, hopefully, minimum trouble to the end user? 有什么好的解决方法,希望对最终用户造成的麻烦最小?

因此,最好的解决方案是使用org.apache.commons.io.FileUtils中的FileUtils.copyFileToDirectory()使用“有效”路径将文件复制到另一个位置。

I found a simple workaround for this problem in Windows. 我在Windows中找到了解决此问题的简单方法。 In my case I'm trying to load the nss native libraries from Mozilla 32 bits installation directory. 就我而言,我试图从Mozilla 32位安装目录中加载nss本机库。 If I configure the path this way: 如果我以这种方式配置路径:

name = NSS
library = C:\Program Files (x86)\Mozilla Firefox\softokn3.dll

I get the Unexpected value Token['('] exception. If instead I trying to add " to enclose the library path: 我收到Unexpected value Token['(']异常。如果相反,我尝试添加"来包围库路径:

name = NSS
library = "C:\Program Files (x86)\Mozilla Firefox\softokn3.dll"

Then the error change and I get: 然后错误更改,我得到:

Caused by: sun.security.pkcs11.ConfigurationException: Absolute path required for library value: C:Program Files (x86)Mozilla Firefoxsoftokn3.dll

So seems that " bypass the parenthesis problem however seems that produce that file.separator is lost, so my last attempt was using " and "escaping" file.separator (simply applying replace("\\\\","\\\\\\\\") to the path before putting in the config): 似乎"绕过括号问题似乎会丢失那个file.separator ,所以我最后一次尝试是使用"和“转义” file.separator (只需应用replace("\\\\","\\\\\\\\")到配置之前的路径):

name = NSS
library = "C:\\Program Files (x86)\\Mozilla Firefox\\softokn3.dll"

This way the library is correctly loaded. 这样可以正确加载库。 I test it for java 8 update 141. 我针对Java 8更新141进行了测试。

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

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