SSL, Tomcat and Grails

How to set this up depends how you are deploying your grails app.

If you are deploying to a container like tomcat, install and configure SSL as you normally would. Then just build a war file with grails war and deploy normally. For tomcat in particular, open the top level tomcat server.xml and add an SSL Connector like so:

<Connector port="8443" maxHttpHeaderSize="8192"
    maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
    enableLookups="false" disableUploadTimeout="true"
    acceptCount="100" scheme="https" secure="true"
    clientAuth="false" sslProtocol="TLS"
    SSLEngine="on"
    SSLCertificateFile="/path/to/cert.pem"
    SSLCertificateKeyFile="/path/to/key.pem"
    SSLPassword="passphrase"
     />

Adjust the connector port to 443 to accept SSL requests directly on the default port. Then drop your war file into the webapps folder.

For the embedded development server (jetty), import your cert into a keystore with keytool and put it in the grails work directory under ssl/keystore. This will look something like $HOME/.grails/1.2.1/ssl/keystore. The keystore password must be “123456”. Then run grails with grails run-app --https. Grails will create the keystore file if it doesn’t exists, but won’t overwrite it if you replace it with your own.

Leave a Comment