Showing posts with label SSL. Show all posts
Showing posts with label SSL. Show all posts

Wednesday, October 7, 2009

Making SSL calls with Grails

All of a sudden I realised that I have to call a service I have behind a SSL connection.

Using grails, this is easy to set up. Just create a couple of Groovy-classes and use it from the controller. It may be nescessary though to add the certificat of the SSL site to your JVM.

Adding the certificate
  • download  the certificate you need, name it to something usefull, for example theSite.cer.
  • use keytool to add it. (needs JAVA_HOME/bin in the path)
keytool -import -keystore /pathToJava/jre/lib/security/cacerts -file theSite.cer 

Class to make the call
this is the class to actually do the work, calling the SSL url you want to reach.
Class for password authentication
this class is needed to authenticate you at the remote site.

In the controller you can then use the class to get a responsestring from the remote server.


/Peter