Search code examples
javassljarjksgrizzly

Setting Grizzly's keystore to use a jks in a jar


I'm trying to use com.sun.grizzly.SSLConfig.setKeyStoreFile() to set SSL for Grizzly. It only takes a String as input (not InputStream or File). I want to use a jks file that is within a JAR file. If I pass a string for a jar path (eg C:\dir\my.jar!\resources\my.jks), it fails. Other than just unzipping the file from the JAR, how can I use that JKS for grizzly.


Solution

  • It doesn't appear you can pass in anything other than a filename. If you view the source and look at the validateConfiguration() and createSSLContext() methods, you'll see that it is passing the keyStoreFile variable directly into the FileInputStream constructor.

    Short term, you're probably stuck with unzipping and using the direct file name. Or you could override the two methods listed above to properly validate and initialize the SSLContext. Long term, I'd submit a patch.