0

I'm trying to pull certificate data from an nss db using Java. Here is my code:

try {
        char[] password = new char[0];
        Provider nss = new sun.security.pkcs11.SunPKCS11("C:\\ntdps_temp\\proj\\NSSdb\\scripts\\pkcs11.cfg");
        Security.addProvider(nss);
        KeyStore ks = KeyStore.getInstance("PKCS11", nss);
        ks.load(null, password);
        for (Enumeration<String> aliases = ks.aliases(); aliases.hasMoreElements();) {
            System.out.println(aliases.nextElement());
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

Here is pkcs11.cfg:

name = NSSdb
nssModule = keystore
nssDbMode = readWrite
nssLibraryDirectory = C:\ntdps_temp\proj\NSSdb\lib
nssSecmodDirectory = C:\ntdps_temp\proj\NSSdb

Here is my stack trace:

java.security.ProviderException: Could not initialize NSS
        at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.java:212)
        at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.java:103)
        at exportnssdb.ExportNssDb.main(ExportNssDb.java:30)
Caused by: java.io.IOException: The specified module could not be found.

        at sun.security.pkcs11.Secmod.nssLoadLibrary(Native Method)
        at sun.security.pkcs11.Secmod.initialize(Secmod.java:210)
        at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.java:207)
        ... 2 more

Note line 30 refers to line Provider nss = new sun.security.pkcs11.SunPKCS11("C:\\ntdps_temp\\proj\\NSSdb\\scripts\\pkcs11.cfg"); here

I am running 32 bit Java for this particular program. Thanks in advance for any help

sufah1
  • 81
  • 7

0 Answers0