Forcing the use of SSL automatically from HTTP request on Tomcat

Hi All,

In this article I will show how we can secure the application resources by converting the HTTP request to HTTPS request.

This is also known as Forcing the use of SSL.

A security constraint can be set up to force certain areas of your application (or your entire application) into SSL mode. This is useful if those resources will be used for confidential information, such as login details or the entry of credit card details.

To implement this we just have to make changes in web.xml by creating a <transport-guarantee element> in a <user-data-constraint> element.

<<Even this works well in JBoss and Weblogic >>

<security-constraint>

<web-resource-collection>

<web-resource-name>MyApplication</web-resource-name>

<!– Protect all resources –>

<url-pattern>/*</url-pattern>

</web-resource-collection>

<!– All access to the application resources is going to SSL protected –>

<user-data-constraint>

<transport-guarantee>CONFIDENTIAL</transport-guarantee>

</user-data-constraint>

</security-constraint>

[Note] On Tomcat Make sure your standard HttpConnector in server.xml has redirectPort=”YOUR_SSL_PORT”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s