1

私はNSSを始めていて、それを構築することができました。結果は、という名前のフォルダーに配置され、distいくつかのexeのdllなどを含むいくつかのサブフォルダーがあります.

dist  
    /WINNT6.0_DBG.OBJ  
         /bin  
         /include  
         /lib   

私はそれを試してみていますが、nssLibraryDirectoryとが何であるかわかりませんnssSecmodDirectory

のすべてを1 つのファイルnssLibraryDirectoryにコピーしてから参照する必要がありますか? どうですか?Sun の pkcs11 の使用を開始するためにどのように構成すればよいかわかりません。 distnssLibraryDirectorynssSecmodDirectory

たとえば、この些細なこと:

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(ネイティブメソッド)

4

2 に答える 2

0

nssLibraryDirectoryには、libサブディレクトリのみを含める必要があります。また、環境変数を変更するか、JVMパラメーターで指定することにより、PATHに表示する必要があります。

于 2011-11-15T08:00:37.193 に答える
0

私の努力からのメモ.... NSSを使いたい人なら誰でも役立つと思います。

Stringどの行でエラーが発生したかを知るために、Java コードを作成する傾向があります。Eclipse はすべての String 構築エラーを排除できるため、そのほうが優れていると言わざるを得ません。次に、入力する値に注意を払います。

私はこれらのコードを使用します:

String config = "xxxxxxx" +
                "xxxxxxx" +
                "xxxxxxx" +
                "\n";
provider = new SunPKCS11(new ByteArrayInputStream(config.getBytes()));
Security.insertProviderAt(provider, 1);

プロバイダー構成のすべてのフラグ: ( http://j7a.ru/_config_8java_source.htmlから、 openjdk 8 のようですsun.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/false

の例nssArgs=: (スペース区切り)

"nssArgs=\"configdir='" + NSS_JSS_Utils.getFireFoxProfilePath() + "' "
+ "certPrefix='' "                          
+ "keyPrefix='' "
+ "secmod='secmod.db' "
+ "flags='readOnly'\""

Java コードでのエスケープの例:

String config = "name=\"NSS Module\"\n" +
                "......" +
                "\n";

スペースがある場合は、で引用する必要があります" "' '使用できません。every"は でエスケープする必要があります\

さて、実際の例をいくつか。

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 ライブラリ libs があるディレクトリを返します。デフォルトでインストールされる場合もありますが (たとえば、私の RedHat 7.2 では)、手動でインストールする必要がある場合もあります。

NSS_JSS_Utils.getFireFoxProfilePath()FireFox プロファイルの場所を返します。NSS/NSPR に同梱されているものを使用すると、インストールされたセキュリティ モジュールがこのフォルダにmodutil格納されていることがわかります。secmod.dbそれらが見つからない場合は、間違ったファイルを取得した可能性があります。

これらの値を埋める方法の詳細:

NSS PKCS#11 仕様

于 2016-11-10T08:35:05.220 に答える