Search code examples
grailssslopensslkeystorex509

Grails 2.4.x setting keystore at runtime


Before upgrading to Grails 2.4.x (I was using Grails 2.2.x) I set my SSL keystore using system properties within the Grails Bootstrap class as follows:

 System.setProperty('javax.net.ssl.keyStore', path)
 System.setProperty('javax.net.ssl.keyStorePassword', password)
 System.setProperty('sun.security.ssl.allowUnsafeRenegotiation', 'true')

This worked fine in 2.2.x and the scribe-java library was able to provide the client certificate to my oauth provider without issue.

It seems after upgrading to Grails 2.4.x, this no longer works - the provider can't see the certificates leading me to assume that the keystore is not being loaded.

Is it the case that Bootstrap is run at a different time in when the application boots up in the new version of Grails - meaning that the keystore has already been loaded before I get a chance to modify the path?

Really very stuck on this one at the moment as keystore loading seems to be a bit of a black box in the Java world, debugging it is nigh on impossible.


Solution

  • So it was my fault entirely - what I'd done is override the trustStore implementation so that I could mock out some SSL APIs.

    It should be unrelated (as far as I can determine), but once I'd removed my 'open' trustStore implementation, the other stuff worked perfectly.

    I guess the real answer to this question is - if you are having trouble with *stores, look at your other *stores code first!