Question

I am trying to setup Jetty to use NSS as its cryptographic engine. I have gotten it to the point where the server starts BUT any client that tries to connect seems to hang in the browser.

The setup process / code I am following is as follows (32-bit Windows 1.6 JVM).

NSS Database Creation

modutil.exe -create -dbdir C:\nssdb
modutil.exe -create -fips true -dbdir C:\nssdb
modutil.exe -create -changepw "NSS FIPS 140-2 Certificate DB" -dbdir C:\nssdb

Load NSS into Java

String config = "name = NSS\n";
config += "nssLibraryDirectory = C:\\nss\\lib\n";
config += "nssSecmodDirectory = C:\\nssdb\n";
config += "nssDbMode = readWrite\n";
config += "nssModule = fips";

InputStream stream = new ByteArrayInputStream(config.getBytes("UTF-8"));

Provider nss = new sun.security.pkcs11.SunPKCS11(stream);
Security.addProvider(nss);

int sunJssePosition = -1;
int currentIndex = 0;
for (Provider provider : Security.getProviders()) {
    if ("SunJSSE".equals(provider.getName())) {
        sunJssePosition = currentIndex + 1;
        break;
    }

    currentIndex++;
}

Security.removeProvider("SunJSSE");

Provider sunJsse = new com.sun.net.ssl.internal.ssl.Provider(nss);
if (sunJssePosition == -1) {
    Security.addProvider(sunJsse);
} else {
    Security.insertProviderAt(sunJsse, sunJssePosition);
}

NSS Self Sign Certificate Generation

C:\nss\bin\certutil.exe -S -n 127.0.0.1 -x -t "u,u,u" -s "CN=127.0.0.1, OU=Foo, O=Bar, L=City, ST=NY, C=US" -m 25001 -d C:\nssdb

Jetty Startup

    KeyStore ks = KeyStore.getInstance("PKCS11");
    ks.load(null, "SuperSecret");

    //Start setting up Jetty
    Server server = new Server();

    SslContextFactory sslContextFactory = new SslContextFactory();
    //sslContextFactory.setKeyStoreProvider("SunPKCS11-NSS");
    sslContextFactory.setKeyStore(ks);
    //sslContextFactory.setKeyStorePassword(new String("SuperSecret"));

    SslSelectChannelConnector sslConnector = new SslSelectChannelConnector(sslContextFactory);
    sslConnector.setPort(443);
    server.addConnector(sslConnector);

    WebAppContext context = new WebAppContext();

    //Blah Blah Blah, setup Jetty

    server.setHandler(context);

    server.start();
    server.join();

Any ideas?


Edit: This seems extremely odd but I can access the server using Internet Explorer just fine. Firefox seems to be the one having an issue.

Was it helpful?

Solution

I have solved the issue. It turns out there are severe bugs in the Java 6 SSL implementation. The solution? Switch to Java 7!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top