Copyright © 2006 by BOTTE Pascal
| Abstract |
Configure Tomcat with SSL to use secure web services isn't so difficult. You can even sign yourself your certificate, follow me... |
We start here with the Tomcat configuration, following this article you should be able to start Tomcat using SSL, server authentication and connect with your web browser, using https, on the end point interface of a secure web service. The first step is to have Tomcat up and running on port 80 or 8080 with a web service configured for public http request. See my web service at my home page (not 24/24 on-line, sorry). Once this step is working you have few change to make on an usual JAX-RPC SOAP client to consume this web service using https.
The first think to do is to configure a new connector in Tomcat, in fact an SSL [1] connector. An SSL connector will be used to listen for https request on a specific port on your server. In the example below you will find a template connector for Tomcat. You can copy/paste and adapt in your server configuration file or use your Tomcat Administration interface to generate an https connector.
In order to be able to start our Tomcat web server, we need to create some file and password to use server authentication:
This file will hold our server certificate (private and public key) used on the server-side to encrypt a message with the private key and let the client decrypt this message with the public key.
The password allowing the server to access the private and public key stored in server.jks.
Next section we will describe a way to create a server certificate for use with Tomcat. I will cover the server-authentication case first. So only the server need to have a private key (kept secret on the server) and a public key (sent to the client) allowing the client to decrypt the received message. The client will need to trust the public key received by comparing it with a trust-store (a keystore file on the client-side) containing only the public key commonly called: certificate.
We need now to create a server-certificate. We can do that easily using the keytool tool shipped with the java sdk. But we have first to understand how certificate and authentication work under SSL.
Usually, once you have created, with keytool, your keystore containing private and public key, you need to generate a certificate signing request. This "csr" will be sent to a Certificate Authority (CA). This CA will digitally sign your csr and sent it back to you. At this point, you have to import your signed certificate into your keystore and your server can start to use it.
The purpouse to have your certificate signed by a CA is very simple: only the CA are registered in the browsers. And therefore all the certificates signed by an officially CA will be automatically trusted by browsers. And because of that your SOAP client need a trust-store containing either the server-certificate (signed or not), or if it is signed (by a CA) only the CA certificate (the public key of the CA).
| [1] | SSL: secure socket layer |