SSL, Tomcat and Grails

13,208

Solution 1

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.

Solution 2

You can run grails run-app -https instead of grails run-app and it will create a self-signed certificate for you and run in SSL.

Share:
13,208
WaZ
Author by

WaZ

Updated on June 07, 2022

Comments

  • WaZ
    WaZ almost 2 years

    I want to implement SSL in Grails. I cannot find the file /conf/server.xml in Grails folder structure. Has anyone implemented it?

    Any help is much appreciated.