Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configure SSL to work with Java web app on Tomcat 5.5 server

This is a bit of a noob question but what do I need to get SSL working in my Java web application (standard sort of Java web app using Stripes for its MVC implementation, Spring and Hibernate)?

I'm deploying my war file on Tomcat 5.5. I only want SSL to be used for certain URLS - any that are transferring the user's password - so account registration, change password, and login.

Do I just need to get an SSL cert and install it in Tomcat? How do I ensure https is used for only some URLs?

like image 285
JMM Avatar asked Jun 21 '10 14:06

JMM


People also ask

Does Tomcat use SSL?

If you're using Apache Tomcat, chances are that at least some of the data you're handling is sensitive, and SSL is an easy way to offer your users security. The good news is that Tomcat fully supports the SSL protocol.


2 Answers

Do I just need to get an SSL cert and install it in Tomcat?

That will be required indeed and you'll need to configure a secured connector.

How do I ensure https is used for only some URLs?

The recommendation is to encrypt form submission (i.e. use absolute https:// urls in the relevant form action) but also form submission pages themselves if you want to prevent man in the middle attacks.

So use "secured" absolute links everywhere you need and enforce SSL for specific content using security constraints in your web.xml:

<security-constraint>
    <web-resource-collection>
        <web-resource-name>Secure Area</web-resource-name>
        <url-pattern>/secure/*</url-pattern>
        <http-method>GET</http-method>
        <http-method>POST</http-method>
    </web-resource-collection>
    <user-data-constraint>
        <transport-guarantee>CONFIDENTIAL</transport-guarantee>
    </user-data-constraint>
</security-constraint> 
like image 79
Pascal Thivent Avatar answered Oct 19 '22 15:10

Pascal Thivent


You can make a Filter that redirects to https:// for the URLs you want.

like image 43
Bozho Avatar answered Oct 19 '22 15:10

Bozho