Issue Details (XML | Word | Printable)

Key: JETTY-456
Type: Improvement Improvement
Status: Resolved Resolved
Resolution: Fixed
Priority: Minor Minor
Assignee: Unassigned
Reporter: Bruno Harbulot
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Jetty

SSL keystores that do not require an InputStream

Created: 03/Nov/07 10:54 AM   Updated: 04/Nov/07 08:02 PM   Resolved: 04/Nov/07 08:02 PM
Return to search
Component/s: Security and SSL
Affects Version/s: 6.1.6rc0
Fix Version/s: 6.1.6rc1

Time Tracking:
Not Specified

File Attachments: 1. Text File SslSocketConnector.java.patch (3 kB)

Environment: Mac OSX (10.4, not tried with 10.5), and perhaps other types of keystores (e.g. PKCS#11)

Patch Submitted: Yes


 Description  « Hide

Some types of keystores do not require a file or an InputStream to be used.
Indeed, Apple's KeychainStore is a keystore that can interact directly with the keychain in OSX. Other such keystores could be hardware tokens.

For example, the following statements will load the default keychain keystore and delegate the task of prompting for a password to the underlying security infrastructure of OSX:
KeyStore ks = KeyStore.getInstance("KeychainStore");
ks.load(null,null);

However, Jetty's SslSocketConnector considers a null keystore parameter (<Set name="keystore"></Set> in the connector configuration) as an absent keystore (it doesn't even try to get the instance and load it).

Here is a patch that should make possible to use a keystore that can have a null InputStream. It works on OSX (with the default keychain) using this configuration (in jetty-ssl.xml, for example):
<Set name="keystoreType">KeychainStore</Set>
<Set name="keystore"></Set>
<Set name="password">-</Set>
<Set name="keyPassword">-</Set>
<Set name="truststoreType">KeychainStore</Set>
<Set name="truststore"></Set>
<Set name="trustPassword">-</Set>

For some reason I ignore, although the password are in fact asked by the keychain mechanism of OSX, empty or null passwords do not work for getting a private key.
Both keyStore.getKey(alias, "-".toCharArray()) and keyStore.getKey(alias, "whateveryoulike".toCharArray()) work (irrespectively of the actual password), but keyStore.getKey(alias, null) or keyStore.getKey(alias, "".toCharArray()) will fail. Hence, the passwords in the configuration above use a dummy non-empty value.

(I submitted a similar patch for Tomcat if this may be relevant: http://issues.apache.org/bugzilla/show_bug.cgi?id=43094 )



Greg Wilkins added a comment - 04/Nov/07 08:02 PM

Patch applied thanks!

I have also done similar for SslSelectChannelConnector
also I allow null passwords if you really want them.


Greg Wilkins made changes - 04/Nov/07 08:02 PM
Field Original Value New Value
Fix Version/s 6.1.6rc1 [ 13653 ]
Status Open [ 1 ] Resolved [ 5 ]
Resolution Fixed [ 1 ]