Book Image

Spring Cookbook

Book Image

Spring Cookbook

Overview of this book

Table of Contents (19 chapters)
Spring Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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 name?
      [Unknown]:  
    What is the name of your organizational unit?
      [Unknown]:  
    What is the name of your organization?
      [Unknown]:  
    What is the name of your City or Locality?
      [Unknown]:  
    What is the name of your State or Province?
      [Unknown...