0

I'm writing a Grails plugin for internal Grails apps to use. I need the plugin to install a truststore (and inside of it, an added SSL cert) and make it available to whatever Grails app includes it as a compile-time plugin.

Hence, if my truststore is called cacerts.jks, and the name of the SSL cert stored therein is called myssl.cer, when the user adds the following to their Grails app's BuildConfig.groovy:

plugins {
    compile  ":myplugin:VERSION"
}

...then the Grails app will trust the myssl.cer that is stored in its JKS.

Any ideas as to how to accomplish this?

DirtyMikeAndTheBoys
  • 1,077
  • 3
  • 15
  • 29
  • 1
    Sounds like you want to make your plugin install the cert when the application starts up. If so then http://stackoverflow.com/a/18889390/877391 that should give you a pointer on how to install the cert into your JVM at run time and you could hook into the doWithApplicationContext event of your plugin as a place to do so (see: http://grails.org/doc/2.3.7/guide/plugins.html#hookingIntoBuildEvents) – Joshua Moore Apr 30 '14 at 17:39
  • Thanks @JoshuaMoore (+1) - sorry but 3 followups: (1) so would I put the code from the first line (`KeyStore keystore = ...`) inside of `Bootstrap.groovy`? (2) Does the `doWithApplicationContext` event occur when Grails loads the plugin and performs all of its Spring injection? And (3) Can you give a more concrete example of what I would be doing with the `doWithApplicationContext` event? Thanks again! – DirtyMikeAndTheBoys Apr 30 '14 at 18:58
  • No worries. I don't know the actual process of adding a cert like that at run-time I'm just putting the pieces that I can find out there together as ideas for you to explore. So, with that in mind. If I understood your question you want the plugin to register the cert on behalf of your application. If that's true then skip doing anything in bootstrap and use the doWithApplicationContext of your plugin to run whatever code is needed to register the cert. The links provided give you examples of how to register a cert and explain how to work with doWithApplicationContext respectively. – Joshua Moore Apr 30 '14 at 19:09

0 Answers0