17

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.

2 Answers 2

12

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.

Sign up to request clarification or add additional context in comments.

2 Comments

ataylor, Thanks for replying. I have been busy trying to work Grails on a local JBoss. Once I get that bit sorted I will use SSL. If any case you have had any experience of using GRAILS with JBoss please share. Highly appreciated, WB
hi, we have xx.key and xx.crt files. Can these be used instead of pem?
12

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.

6 Comments

Hi Burt, Thanks but I have created a self signed certificate using Java keytool. As in the future I have to use a valid and Veri-Signed SSL.
Slight correction on this, I believe that it's 'grails run-app -https'. Docs: grails.org/doc/2.2.0/ref/Command%20Line/run-app.html
Yep, it has changed since 2010 :)
hey burt.. anyway of doing this without using run-app?
Also note that for some time there was a bug in the Tomcat plugin for Grails that caused an exception to be thrown when using the -https option (MissingMethodException for org.grails.plugins.tomcat.fork.TomcatDevelopmentRunner.loadInstance). Updating the plugin to 7.0.52 or greater should fix. See issue: jira.grails.org/browse/GRAILS-11123
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.