Note that there are some explanatory texts on larger screens.

plurals
  1. POAccess Firefox's certificate trust store from Java
    primarykey
    data
    text
    <p>I'm almost losing hope on this one. I'm trying to access the Firefox trust store from Java 7 using the NSS libraries that come with the Firefox installation, via PKCS#11.</p> <p>Here is the code:</p> <pre><code>import java.security.KeyStore; import java.security.Security; import java.util.Enumeration; import sun.security.pkcs11.SunPKCS11; public class Test { public static void main(String[] args) throws Exception { String configName = "pkcs11.cfg"; SunPKCS11 p = new SunPKCS11(configName); Security.addProvider(p); KeyStore ks = KeyStore.getInstance("PKCS11", p); ks.load(null, "apassword".toCharArray()); System.out.println("Size: " + ks.size()); Enumeration&lt;String&gt; aliases = ks.aliases(); while (aliases.hasMoreElements()) { System.out.println(aliases.nextElement()); } } } </code></pre> <p>Here are the contents for the PKCS#11 config:</p> <pre><code>name = NSS nssLibraryDirectory = /usr/lib/firefox/ nssSecmodDirectory = "/home/bogdan/.mozilla/firefox/x5d8wol9.default/" nssModule =trustanchors showInfo = true </code></pre> <p>When I run the application I also set the property <code>-Djava.library.path=/usr/lib/firefox/</code></p> <p>When I run the application I get the following:</p> <pre><code>NSS modules: [NSS Internal PKCS #11 Module (CRYPTO, /usr/lib/firefox/libsoftokn3.so, slot 0), NSS Internal PKCS #11 Module (KEYSTORE, /usr/lib/firefox/libsoftokn3.so, slot 1)] Exception in thread "main" java.security.ProviderException: NSS module not available: trustanchors at sun.security.pkcs11.SunPKCS11.&lt;init&gt;(SunPKCS11.java:271) at sun.security.pkcs11.SunPKCS11.&lt;init&gt;(SunPKCS11.java:103) at Test.main(Test.java:11) </code></pre> <p>You can actually see that the "trustanchors" module is not loaded at the initialisation step, but I have no idea why. The documentation here: <a href="http://docs.oracle.com/javase/6/docs/technotes/guides/security/p11guide.html#NSS" rel="nofollow">http://docs.oracle.com/javase/6/docs/technotes/guides/security/p11guide.html#NSS</a> says that </p> <blockquote> <p>The trustanchors module enables access to NSS trust anchor certificates via the PKCS11 KeyStore, if secmod.db has been configured to include the trust anchor library.</p> </blockquote> <p>but I have no idea what that means. It's worth noting that I get the same behaviour with both Windows XP 32 bit and Ubuntu 11.10 64-bit. It seems that the pkcs11.cfg is correct as if I change any of the paths the application will fail with other errors.</p> <p>Any bright ideas?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload