Archive

Archive for the ‘tomcat’ Category

tomcat – configure SSL/HTTPS

  1. >cd $CATALINA_HOME
  2. $JAVA_HOME/keytool -genkey -alias tomcat -keyalg RSA -keystore mycert.jks
  3. Enter keystore password: changeit
  4. What is your first and last name? : Aravind Kopparthi
  5. What is the name of your organizational unit? [Unknown]: CAT
  6. What is the name of your organization? [Unknown]: GOOGLE
  7. What is the name of your City or Locality? [Unknown]: FL
  8. What is the name of your State or Province? [Unknown]: FL
  9. What is the two-letter country code for this unit? [Unknown]: US
  10. US Is CN=Danesh Manoharan, OU=IT, O=”My Comp.”, L=KL, ST=KL, C=MY correct? [no]: yes
  11. Enter key password for (RETURN if same as keystore password): Hit Enter.

Tomcat will assume the password is “changeit” by default so it’s advised to leave it that way. Now let’s tell Tomcat to use the keystore file.

  1. cd $CATALINA_HOME/conf/
  2. vi server.xml
  3. Look for “<!– Define a SSL HTTP/1.1 Connector on port 8443 –>”. Remove the <!– –> comments indicator and add the keystore info.

<!– Define a SSL HTTP/1.1 Connector on port 8443 –>
<Connector port=”443” maxHttpHeaderSize=”8192″
maxThreads=”150″ minSpareThreads=”25″ maxSpareThreads=”75″
enableLookups=”false” disableUploadTimeout=”true”
acceptCount=”100″ scheme=”https” secure=”true”
keystoreFile=”/opt/Tomcat5/mycert.jks
clientAuth=”false” sslProtocol=”TLS” />

Time to restart Tomcat and test.

  1. cd $CATALINA_HOME/bin/
  2. ./shutdown.sh to make sure Tomcat is down.
  3. ./startup.sh to start Tomcat.
  4. Fire up your browser and test your new https site. https://localhost:9080/
Categories: tomcat Tags: , ,

Tomcat – Use catalina servlet to disable file listing…

1. Edit the default servlet in the {$CATALINA_HOME}/conf/web.xml file.

2. Look for the <init-param> section within the <servlet section>

<servlet>
<servlet-name>default</servlet-name>
<servlet-class>
org.apache.catalina.servlets.DefaultServlet
</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>listings</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

3. Change the <param-value> to false for the <param-name>listing</param-name> section.

<init-param>
<param-name>listings</param-name>
<param-value>false</param-value>
</init-param>

Categories: tomcat Tags:
Follow

Get every new post delivered to your Inbox.