Nav Bar

jueves, 14 de febrero de 2013

Setting SSL in Tomcat with Java apps

Good afternoon, at least in Spain. Today we are going to learn how to set up SSL security on a Apache Tomcat server running our Java, or similar, app.
First of all, we must create a Keystore file using Java. Go to your JDK folder: cd $JAVA_HOME/bin. Now, create the keystore file: keytool -genkey -alias tomcat -keyalg RSA -keystore. Bare in mind that the password for the keystore must be the same as the key password. This is a tomcat limitation that I didn’t find anywhere. Took me a whole morning to find out. If everything is correct, you should have the .keystore file in the folder you where in (JDK/bin). The next step is to copy this .keystore file wherever you want it to be.
There is a possibility to change the password for the key file using the following command: keystore -keypasswd -alias tomcat -keystore
Now, let’s move on. Open your server.xml file. Inside the conf folder, in $CATALINA_HOME. You have to declare a new Connector:

Our last step to follow is  to configure the web.xml file for our app. Then we will be able to run SSL. It should be inside your webapps/appFolder folder. Insert the following lines after declaration.

 
  securedapp
  /*
 

 
  CONFIDENTIAL
 
If you want to quit SSL, just change CONFIDENTIAL to NONE, so you don’t have to delete all the code written. Hope you found it interesting.

Resources:
Resource 1
Resource 2

lunes, 4 de febrero de 2013

Startup script in Ubuntu

Today I learned how to make a script run on sytem startup. This way you can run your script after rebooting automatically. Let’s take a look at the steps:

1. Open /etc/init.d/rc.local file.

2. Add the script you want to run on boot process there. For example:

    sh /usr/share/apache-tomcat-7.0.27/bin/startup.sh
    echo ‘Apache Tomcat Running’

3. Save the file. Your script will run on boot process.