Using HTTPS with Tomcat

To use HTTPS URLs, no Spring configuration is required, but you need to enable HTTPS on your server. In this recipe, we'll cover how to do this for Tomcat (on a Mac OS or Linux) using a self-generated SSL certificate. For production, remember to use a real commercial SSL certificate.

How to do it…

Here are the steps to enable HTTPS for Tomcat:

  1. To generate an SSL certificate, open a Terminal and use the keytool command to create certificate.bin. In this example, the certificate user name is admin and the password is adminpass:
    keytool -genkey -alias admin -keypass adminpass -keystore certificate.bin -storepass adminpass
  2. Accept the default values, except for the last question whose answer should be yes:
    What is your first and last ...

Get Spring Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.