我开始进入NSS,我成功地建立了它。结果被放置在一个名为dist的文件夹中,并且有几个子文件夹,其中包含了几个exe的dll等等。
dist
/WINNT6.0_DBG.OBJ
/bin
/include
/lib 我正在尝试尝试,但我不确定nssLibraryDirectory和nssSecmodDirectory是什么。
对于nssLibraryDirectory,我应该在一个文件中复制dist中的所有内容并从nssLibraryDirectory引用它吗?那nssSecmodDirectory呢?我不知道该如何配置开始使用sun的pkcs11。
例如,这个琐碎的:
String configName = "nss.cfg";
Provider p = new sun.security.pkcs11.SunPKCS11(configName );其中nss.cfg是:
name = NSS
nssLibraryDirectory = E:\NSS\nss-3.12.4-with-nspr-4.8\mozilla\dist\WINNT6.0_DBG.OBJ\lib
nssDbMode = noDb 给予例外
由:java.io.IOException引起:找不到指定的模块。在sun.security.pkcs11.Secmod.nssLoadLibrary(Native方法中)
发布于 2011-11-15 08:00:37
nssLibraryDirectory应该只包含lib子目录。它还必须出现在PATH中--要么修改环境变量,要么在JVM参数中指定它。
发布于 2016-11-10 08:35:05
一些来自我的努力..。我认为这对任何想要使用NSS的人都有帮助。
我倾向于在Java代码中构造一个String,以知道错误发生在哪一行。我必须说它更好,因为Eclipse可以消除所有字符串构造错误。然后,你要注意要填写的价值观。
我使用以下代码:
String config = "xxxxxxx" +
"xxxxxxx" +
"xxxxxxx" +
"\n";
provider = new SunPKCS11(new ByteArrayInputStream(config.getBytes()));
Security.insertProviderAt(provider, 1);提供程序配置的所有标志:(来自source.html,类似于openjdk 8sun.security.pkcs11.Config.java)。
name=xxxxxx //some text, " must be escaped with \
library=/location/of/your/.so/or/.dll/file //not compatible with NSS mode, must be quoted if contains space, and if quoted, " must be escaped
description=
slot= //not compatible with NSS mode
slotListIndex= //not compatible with NSS mode
enableMechanisms=
disableMechanisms=
attributes=
handleStartupErrors=
insertionCheckInterval=
showInfo=true/false
keyStoreCompatibilityMode=
explicitCancel=
omitInitialize=
allowSingleThreadedModules=
functionList=
nssUseSecmod=true/false //not campatible with 'library'
nssLibraryDirectory= //not campatible with 'library'
nssSecmodDirectory= //not campatible with 'library'
nssModule=some text //not campatible with 'library'
nssDbMode=readWrite, readOnly, noDb //not campatible with 'library'
nssNetscapeDbWorkaround=true/false //not campatible with 'library'
nssArgs="name1='value1' name2='value2' name3='value3' ... " //not compatible with NSS mode
nssUseSecmodTrust=true/falsenssArgs=示例:(按空间分隔)
"nssArgs=\"configdir='" + NSS_JSS_Utils.getFireFoxProfilePath() + "' "
+ "certPrefix='' "
+ "keyPrefix='' "
+ "secmod='secmod.db' "
+ "flags='readOnly'\""在Java代码中转义的一些示例:
String config = "name=\"NSS Module\"\n" +
"......" +
"\n";如果使用空格,则必须用" "引用。' '无法使用。每个"都必须用\转义。
现在,一些真实的例子。
要通过NSS使用Firefox安全模块:
String config = "name=\"NSS Module\"\n"
+ "attributes=compatibility\n"
+ "showInfo=true\n"
+ "allowSingleThreadedModules=true\n"
+ "nssLibraryDirectory=" + NSS_JSS_Utils.NSS_LIB_DIR + "\n"
+ "nssUseSecmod=true\n"
+ "nssSecmodDirectory=" + NSS_JSS_Utils.getFireFoxProfilePath();要使用libsoftokn3.so (我不知道它用于什么,但我看到有人在nssArgs中这样使用它):
String config = "library=" + NSS_JSS_Utils.NSS_LIB_DIR + "/libsoftokn3.so" + "\n"
+ "name=\"Soft Token\"\n";
+ "slot=2\n"
+ "attributes=compatibility\n"
+ "allowSingleThreadedModules=true\n"
+ "showInfo=true\n"
+ "nssArgs=\"configdir='" + NSS_JSS_Utils.getFireFoxProfilePath() + "' "
+ "certPrefix='' "
+ "keyPrefix='' "
+ "secmod='secmod.db' "
+ "flags='readOnly'\""
+ "\n";NSS_JSS_Utils.NSS_LIB_DIR返回所有NSS库的目录。有时它们是默认安装的(例如,在我的RedHat 7.2中),但有时您必须手动安装它们。
NSS_JSS_Utils.getFireFoxProfilePath()返回您的FireFox配置文件所在的位置。如果使用NSS/NSPR附带的modutil,您可以看到已安装的安全模块存储在此文件夹中的secmod.db中。如果您找不到它们,您可能拿错了文件。
有关如何填充这些值的更多信息:
https://stackoverflow.com/questions/6170358
复制相似问题