The Public Key Infrastructure is used to create this environment.
The Certificate is cryptographically signed by its owner and is difficult for anyone else to forge. For sites involved in e-commerce, or any other business transaction in which authentication of identity is important, a certificate can be purd from a well-known Certificate Authority (CA) such as Verisign or Thawte.
If authentication is not really a concern, such as if an administrator simply wants to ensure that data being transmitted and received by the server is private and cannot be snooped by anyone eavesdropping on the connection, you can simply save the time and expense involved in obtaining a CA certificate and simply use a self-signed certificate.
Certificates are used with the HTTPS protocol to authenticate Web clients. The HTTPS service of the Tomcat server will not run unless a server certificate has been installed. Use the procedure outlined below to set up a server certificate that can be used by Tomcat to enable SSL.
One tool that can be used to set up a Tomcat server certificate is keytool, a key and certificate management utility. It enables users to administer their own public/private key pairs and associated certificates for use in self-authentication (where the user authenticates himself/herself to other users/services) or data integrity and authentication services, using digital signatures. It also allows users to cache the public keys (in the form of certificates) of their communicating peers.
A certificate is a digitally-signed statement from one entity (person, company, etc.), saying that the public key (and some other information) of some other entity has a particular value. When data is digitally signed, the signature can be verified to check the data integrity and authenticity. Integrity means that the data has not been modified or tampered with, and authenticity means the data indeed comes from whoever claims to have created and signed it.
The keytool stores the keys and certificates in a so-called keystore. The default keystore implementation implements the keystore as a file. It protects private keys with a password. For more information on keytool, read its documentation at http://java.sun.com/j2se/1.4/docs/tooldocs/solaris/keytool.html.
keytool -genkey -keyalg RSA -alias tomcat -keystore <keystore_filename>Note: Tomcat is looking for the keystore to have the name .keystore in the home directory of the machine on which Tomcat is running. As this is not very well suited for a server based application, we reccomend <$CATALINA_HOME/bin/.keystore> be used for the <keystore_filename>.
The keytool utility prompts you for the following information:
A self-signed certificate is acceptable for most SSL communication. If you are using a self-signed certificate, skip to Configuring the SSL Connector. If you'd like to have your certificate digitally signed by a CA, continue with Obtaining a Digitally-Signed Certificate.
keytool -certreq -alias tomcat -keyalg RSA -file <csr_filename> -keystore <keystore_filename>
keytool -import -alias root -trustcacerts -file <signed_cert_file> -keystore <keystore_filename>
keytool -import -trustcacerts -alias tomcat -file <ca-cert-filename> -keystore <trustcacerts-filename>NOTE:We recommend that the <trustcacerts-filename> be <$CATALINA_HOME/conf/cacerts>
An example Connector element for an TLS connector is included in the default server.xml. This Connector element is commented out by default. To enable the TLS Connector for Tomcat, remove the comment tags around the SSL Connector element. To do this, follow these steps.
<!-- SSL Connector on Port 8443 --> <!-- <Connector className="org.apache.coyote.tomcat4.CoyoteConnector" port="8443" minProcessors="5" maxProcessors="75" enableLookups="false" acceptCount="10" connectionTimeout="60000" debug="0" scheme="https" secure="true"> <Factory className="org.apache.coyote.tomcat4. CoyoteServerSocketFactory" clientAuth="false" protocol="TLS" /> </Connector> -->
Edit this section so the section looks similar to:
<Connector protocol="org.apache.coyote.http11.Http11NioProtocol" port="8443" SSLEnabled="true" maxThreads="200" disableuploadtimeout="true" scheme="https" secure="true" keystoreFile="/usr/share/tomcat/conf/ldapwiki.jks" keystorePass="secret" clientAuth="false" sslEnabledProtocols="TLSv1, TLSv1.1, TLSv1.2" ciphers="TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,TLS_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_256_CBC_SHA256,TLS_RSA_WITH_AES_256_CBC_SHA" />
As far as we know, this will pass the SHA-1 Deprecation but we are not confident how many browsers will be able to support this restricted list of Cipher Suite:
<Connector protocol="org.apache.coyote.http11.Http11NioProtocol" port="8443" SSLEnabled="true" maxThreads="200" disableuploadtimeout="true" scheme="https" secure="true" keystoreFile="/usr/share/tomcat/conf/ldapwiki.jks" keystorePass="content-supressed" clientAuth="false" sslEnabledProtocols="TLSv1, TLSv1.1, TLSv1.2" ciphers="TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,TLS_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_256_CBC_SHA256" />
The https in this URL indicates that the browser should be using the SSL protocol. The port of 8443 is where the SSL Connector was created in the previous step.
The first time a user loads this application, the New Site Certificate dialog displays. Select Next to move through the series of New Site Certificate dialogs, select Finish when you reach the last dialog.