Hongqing Liu | 7189829 | 2014-10-15 13:31:32 +0800 | [diff] [blame] | 1 | <html><head><META http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><title>Apache Tomcat 6.0 (6.0.41) - SSL Configuration HOW-TO</title><meta name="author" content="Christopher Cain"><meta name="author" content="Yoav Shapira"><style type="text/css" media="print">
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 2 | .noPrint {display: none;}
|
| 3 | td#mainBody {width: 100%;}
|
| 4 | </style></head><body bgcolor="#ffffff" text="#000000" link="#525D76" alink="#525D76" vlink="#525D76"><table border="0" width="100%" cellspacing="0"><!--PAGE HEADER--><tr><td><!--PROJECT LOGO--><a href="http://tomcat.apache.org/"><img src="./images/tomcat.gif" align="right" alt="
|
| 5 | The Apache Tomcat Servlet/JSP Container
|
Hongqing Liu | 7189829 | 2014-10-15 13:31:32 +0800 | [diff] [blame] | 6 | " border="0"></a></td><td><h1><font face="arial,helvetica,sanserif">Apache Tomcat 6.0</font></h1><font face="arial,helvetica,sanserif">Version 6.0.41, May 19 2014</font></td><td><!--APACHE LOGO--><a href="http://www.apache.org/"><img src="./images/asf-logo.gif" align="right" alt="Apache Logo" border="0"></a></td></tr></table><table border="0" width="100%" cellspacing="4"><!--HEADER SEPARATOR--><tr><td colspan="2"><hr noshade="noshade" size="1"></td></tr><tr><!--LEFT SIDE NAVIGATION--><td width="20%" valign="top" nowrap="nowrap" class="noPrint"><p><strong>Links</strong></p><ul><li><a href="index.html">Docs Home</a></li><li><a href="http://wiki.apache.org/tomcat/FAQ">FAQ</a></li></ul><p><strong>User Guide</strong></p><ul><li><a href="introduction.html">1) Introduction</a></li><li><a href="setup.html">2) Setup</a></li><li><a href="appdev/index.html">3) First webapp</a></li><li><a href="deployer-howto.html">4) Deployer</a></li><li><a href="manager-howto.html">5) Manager</a></li><li><a href="realm-howto.html">6) Realms and AAA</a></li><li><a href="security-manager-howto.html">7) Security Manager</a></li><li><a href="jndi-resources-howto.html">8) JNDI Resources</a></li><li><a href="jndi-datasource-examples-howto.html">9) JDBC DataSources</a></li><li><a href="class-loader-howto.html">10) Classloading</a></li><li><a href="jasper-howto.html">11) JSPs</a></li><li><a href="ssl-howto.html">12) SSL</a></li><li><a href="ssi-howto.html">13) SSI</a></li><li><a href="cgi-howto.html">14) CGI</a></li><li><a href="proxy-howto.html">15) Proxy Support</a></li><li><a href="mbeans-descriptor-howto.html">16) MBean Descriptor</a></li><li><a href="default-servlet.html">17) Default Servlet</a></li><li><a href="cluster-howto.html">18) Clustering</a></li><li><a href="balancer-howto.html">19) Load Balancer</a></li><li><a href="connectors.html">20) Connectors</a></li><li><a href="monitoring.html">21) Monitoring and Management</a></li><li><a href="logging.html">22) Logging</a></li><li><a href="apr.html">23) APR/Native</a></li><li><a href="virtual-hosting-howto.html">24) Virtual Hosting</a></li><li><a href="aio.html">25) Advanced IO</a></li><li><a href="extras.html">26) Additional Components</a></li><li><a href="maven-jars.html">27) Mavenized</a></li></ul><p><strong>Reference</strong></p><ul><li><a href="RELEASE-NOTES.txt">Release Notes</a></li><li><a href="config/index.html">Configuration</a></li><li><a href="api/index.html">Javadocs</a></li><li><a href="http://tomcat.apache.org/connectors-doc/">JK 1.2 Documentation</a></li></ul><p><strong>Apache Tomcat Development</strong></p><ul><li><a href="building.html">Building</a></li><li><a href="changelog.html">Changelog</a></li><li><a href="http://wiki.apache.org/tomcat/TomcatVersions">Status</a></li><li><a href="developers.html">Developers</a></li><li><a href="architecture/index.html">Architecture</a></li><li><a href="funcspecs/index.html">Functional Specs.</a></li></ul></td><!--RIGHT SIDE MAIN BODY--><td width="80%" valign="top" align="left" id="mainBody"><h1>Apache Tomcat 6.0</h1><h2>SSL Configuration HOW-TO</h2><table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Table of Contents"><!--()--></a><a name="Table_of_Contents"><strong>Table of Contents</strong></a></font></td></tr><tr><td><blockquote>
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 7 | <ul><li><a href="#Quick_Start">Quick Start</a></li><li><a href="#Introduction_to_SSL">Introduction to SSL</a></li><li><a href="#SSL_and_Tomcat">SSL and Tomcat</a></li><li><a href="#Certificates">Certificates</a></li><li><a href="#General_Tips_on_Running_SSL">General Tips on Running SSL</a></li><li><a href="#Configuration">Configuration</a><ol><li><a href="#Prepare_the_Certificate_Keystore">Prepare the Certificate Keystore</a></li><li><a href="#Edit_the_Tomcat_Configuration_File">Edit the Tomcat Configuration File</a></li></ol></li><li><a href="#Installing_a_Certificate_from_a_Certificate_Authority">Installing a Certificate from a Certificate Authority</a><ol><li><a href="#Create_a_local_Certificate_Signing_Request_(CSR)">Create a local Certificate Signing Request (CSR)</a></li><li><a href="#Importing_the_Certificate">Importing the Certificate</a></li></ol></li><li><a href="#Troubleshooting">Troubleshooting</a></li><li><a href="#Miscellaneous_Tips_and_Bits">Miscellaneous Tips and Bits</a></li></ul>
|
| 8 | </blockquote></td></tr></table><table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Quick Start"><!--()--></a><a name="Quick_Start"><strong>Quick Start</strong></a></font></td></tr><tr><td><blockquote>
|
| 9 |
|
| 10 | <blockquote><em>
|
| 11 | <p>The description below uses the variable name $CATALINA_BASE to refer the
|
| 12 | base directory against which most relative paths are resolved. If you have
|
| 13 | not configured Tomcat 6 for multiple instances by setting a CATALINA_BASE
|
| 14 | directory, then $CATALINA_BASE will be set to the value of $CATALINA_HOME,
|
| 15 | the directory into which you have installed Tomcat 6.</p>
|
| 16 | </em></blockquote>
|
| 17 |
|
| 18 | <p>To install and configure SSL support on Tomcat 6, you need to follow
|
| 19 | these simple steps. For more information, read the rest of this HOW-TO.</p>
|
| 20 | <ol>
|
| 21 | <li>Create a keystore file to store the server's private key and
|
| 22 | self-signed certificate by executing the following command:
|
| 23 | <p>Windows:</p>
|
| 24 | <div align="left"><table cellspacing="4" cellpadding="0" border="0"><tr><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr><tr><td bgcolor="#023264" width="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#ffffff" height="1"><pre>
|
| 25 | %JAVA_HOME%\bin\keytool -genkey -alias tomcat -keyalg RSA
|
| 26 | </pre></td><td bgcolor="#023264" width="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr><tr><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr></table></div>
|
| 27 | <p>Unix:</p>
|
| 28 | <div align="left"><table cellspacing="4" cellpadding="0" border="0"><tr><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr><tr><td bgcolor="#023264" width="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#ffffff" height="1"><pre>
|
| 29 | $JAVA_HOME/bin/keytool -genkey -alias tomcat -keyalg RSA
|
| 30 | </pre></td><td bgcolor="#023264" width="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr><tr><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr></table></div>
|
| 31 | <p></p>
|
| 32 | and specify a password value of "changeit".</li><br><br>
|
| 33 | <li>Uncomment the "SSL HTTP/1.1 Connector" entry in
|
| 34 | <code>$CATALINA_BASE/conf/server.xml</code> and modify as described in
|
| 35 | the <a href="#Configuration">Configuration section</a> below.</li>
|
| 36 | <br><br>
|
| 37 | </ol>
|
| 38 |
|
| 39 |
|
| 40 | </blockquote></td></tr></table><table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Introduction to SSL"><!--()--></a><a name="Introduction_to_SSL"><strong>Introduction to SSL</strong></a></font></td></tr><tr><td><blockquote>
|
| 41 |
|
| 42 | <p>SSL, or Secure Socket Layer, is a technology which allows web browsers and
|
| 43 | web servers to communicate over a secured connection. This means that the data
|
| 44 | being sent is encrypted by one side, transmitted, then decrypted by the other
|
| 45 | side before processing. This is a two-way process, meaning that both the
|
| 46 | server AND the browser encrypt all traffic before sending out data.</p>
|
| 47 |
|
| 48 | <p>Another important aspect of the SSL protocol is Authentication. This means
|
| 49 | that during your initial attempt to communicate with a web server over a secure
|
| 50 | connection, that server will present your web browser with a set of
|
| 51 | credentials, in the form of a "Certificate", as proof the site is who and what
|
| 52 | it claims to be. In certain cases, the server may also request a Certificate
|
| 53 | from your web browser, asking for proof that <em>you</em> are who you claim
|
| 54 | to be. This is known as "Client Authentication," although in practice this is
|
| 55 | used more for business-to-business (B2B) transactions than with individual
|
| 56 | users. Most SSL-enabled web servers do not request Client Authentication.</p>
|
| 57 |
|
| 58 | </blockquote></td></tr></table><table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="SSL and Tomcat"><!--()--></a><a name="SSL_and_Tomcat"><strong>SSL and Tomcat</strong></a></font></td></tr><tr><td><blockquote>
|
| 59 |
|
| 60 | <p>It is important to note that configuring Tomcat to take advantage of
|
| 61 | secure sockets is usually only necessary when running it as a stand-alone
|
| 62 | web server. When running Tomcat primarily as a Servlet/JSP container behind
|
| 63 | another web server, such as Apache or Microsoft IIS, it is usually necessary
|
| 64 | to configure the primary web server to handle the SSL connections from users.
|
| 65 | Typically, this server will negotiate all SSL-related functionality, then
|
| 66 | pass on any requests destined for the Tomcat container only after decrypting
|
| 67 | those requests. Likewise, Tomcat will return cleartext responses, that will
|
| 68 | be encrypted before being returned to the user's browser. In this environment,
|
| 69 | Tomcat knows that communications between the primary web server and the
|
| 70 | client are taking place over a secure connection (because your application
|
| 71 | needs to be able to ask about this), but it does not participate in the
|
| 72 | encryption or decryption itself.</p>
|
| 73 |
|
| 74 | </blockquote></td></tr></table><table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Certificates"><strong>Certificates</strong></a></font></td></tr><tr><td><blockquote>
|
| 75 |
|
| 76 | <p>In order to implement SSL, a web server must have an associated Certificate
|
| 77 | for each external interface (IP address) that accepts secure connections.
|
| 78 | The theory behind this design is that a server should provide some kind of
|
| 79 | reasonable assurance that its owner is who you think it is, particularly
|
| 80 | before receiving any sensitive information. While a broader explanation of
|
| 81 | Certificates is beyond the scope of this document, think of a Certificate
|
| 82 | as a "digital driver's license" for an Internet address. It states what
|
| 83 | company the site is associated with, along with some basic contact
|
| 84 | information about the site owner or administrator.</p>
|
| 85 |
|
| 86 | <p>This "driver's license" is cryptographically signed by its owner, and is
|
| 87 | therefore extremely difficult for anyone else to forge. For sites involved
|
| 88 | in e-commerce, or any other business transaction in which authentication of
|
| 89 | identity is important, a Certificate is typically purchased from a well-known
|
| 90 | <em>Certificate Authority</em> (CA) such as VeriSign or Thawte. Such
|
| 91 | certificates can be electronically verified -- in effect, the Certificate
|
| 92 | Authority will vouch for the authenticity of the certificates that it grants,
|
| 93 | so you can believe that that Certificate is valid if you trust the Certificate
|
| 94 | Authority that granted it.</p>
|
| 95 |
|
| 96 | <p>In many cases, however, authentication is not really a concern. An
|
| 97 | administrator may simply want to ensure that the data being transmitted and
|
| 98 | received by the server is private and cannot be snooped by anyone who may be
|
| 99 | eavesdropping on the connection. Fortunately, Java provides a relatively
|
| 100 | simple command-line tool, called <code>keytool</code>, which can easily create
|
| 101 | a "self-signed" Certificate. Self-signed Certificates are simply user
|
| 102 | generated Certificates which have not been officially registered with any
|
| 103 | well-known CA, and are therefore not really guaranteed to be authentic at all.
|
| 104 | Again, this may or may not even be important, depending on your needs.</p>
|
| 105 |
|
| 106 | </blockquote></td></tr></table><table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="General Tips on Running SSL"><!--()--></a><a name="General_Tips_on_Running_SSL"><strong>General Tips on Running SSL</strong></a></font></td></tr><tr><td><blockquote>
|
| 107 |
|
| 108 | <p>The first time a user attempts to access a secured page on your site,
|
| 109 | he or she is typically presented with a dialog containing the details of
|
| 110 | the certificate (such as the company and contact name), and asked if he or she
|
| 111 | wishes to accept the Certificate as valid and continue with the transaction.
|
| 112 | Some browsers will provide an option for permanently accepting a given
|
| 113 | Certificate as valid, in which case the user will not be bothered with a
|
| 114 | prompt each time they visit your site. Other browsers do not provide this
|
| 115 | option. Once approved by the user, a Certificate will be considered valid
|
| 116 | for at least the entire browser session.</p>
|
| 117 |
|
| 118 | <p>Also, while the SSL protocol was designed to be as efficient as securely
|
| 119 | possible, encryption/decryption is a computationally expensive process from
|
| 120 | a performance standpoint. It is not strictly necessary to run an entire
|
| 121 | web application over SSL, and indeed a developer can pick and choose which
|
| 122 | pages require a secure connection and which do not. For a reasonably busy
|
| 123 | site, it is customary to only run certain pages under SSL, namely those
|
| 124 | pages where sensitive information could possibly be exchanged. This would
|
| 125 | include things like login pages, personal information pages, and shopping
|
| 126 | cart checkouts, where credit card information could possibly be transmitted.
|
| 127 | Any page within an application can be requested over a secure socket by
|
| 128 | simply prefixing the address with <code>https:</code> instead of
|
| 129 | <code>http:</code>. Any pages which absolutely <strong>require</strong>
|
| 130 | a secure connection should check the protocol type associated with the
|
| 131 | page request and take the appropriate action if <code>https</code> is not
|
| 132 | specified.</p>
|
| 133 |
|
| 134 | <p>Finally, using name-based virtual hosts on a secured connection can be
|
| 135 | problematic. This is a design limitation of the SSL protocol itself. The SSL
|
| 136 | handshake, where the client browser accepts the server certificate, must occur
|
| 137 | before the HTTP request is accessed. As a result, the request information
|
| 138 | containing the virtual host name cannot be determined prior to authentication,
|
| 139 | and it is therefore not possible to assign multiple certificates to a single
|
| 140 | IP address. If all virtual hosts on a single IP address need to authenticate
|
| 141 | against the same certificate, the addition of multiple virtual hosts should not
|
| 142 | interfere with normal SSL operations on the server. Be aware, however, that
|
| 143 | most client browsers will compare the server's domain name against the domain
|
| 144 | name listed in the certificate, if any (applicable primarily to official,
|
| 145 | CA-signed certificates). If the domain names do not match, these browsers will
|
| 146 | display a warning to the client user. In general, only address-based virtual
|
| 147 | hosts are commonly used with SSL in a production environment.</p>
|
| 148 |
|
| 149 | </blockquote></td></tr></table><table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Configuration"><strong>Configuration</strong></a></font></td></tr><tr><td><blockquote>
|
| 150 |
|
| 151 | <table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#828DA6"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Prepare the Certificate Keystore"><!--()--></a><a name="Prepare_the_Certificate_Keystore"><strong>Prepare the Certificate Keystore</strong></a></font></td></tr><tr><td><blockquote>
|
| 152 |
|
| 153 | <p>Tomcat currently operates only on <code>JKS</code>, <code>PKCS11</code> or
|
| 154 | <code>PKCS12</code> format keystores. The <code>JKS</code> format
|
| 155 | is Java's standard "Java KeyStore" format, and is the format created by the
|
| 156 | <code>keytool</code> command-line utility. This tool is included in the JDK.
|
| 157 | The <code>PKCS12</code> format is an internet standard, and can be manipulated
|
| 158 | via (among other things) OpenSSL and Microsoft's Key-Manager.
|
| 159 | </p>
|
| 160 |
|
| 161 | <p>Each entry in a keystore is identified by an alias string. Whilst many
|
| 162 | keystore implementations treat aliases in a case insensitive manner, case
|
| 163 | sensitive implementations are available. The <code>PKCS11</code> specification,
|
| 164 | for example, requires that aliases are case sensitive. To avoid issues related
|
| 165 | to the case sensitivity of aliases, it is not recommended to use aliases that
|
| 166 | differ only in case.
|
| 167 | </p>
|
| 168 |
|
| 169 | <p>To import an existing certificate into a JKS keystore, please read the
|
| 170 | documentation (in your JDK documentation package) about <code>keytool</code>.
|
| 171 | Note that OpenSSL often adds readable comments before the key,
|
| 172 | <code>keytool</code>does not support that, so remove the OpenSSL comments if
|
| 173 | they exist before importing the key using <code>keytool</code>.
|
| 174 | </p>
|
| 175 | <p>To import an existing certificate signed by your own CA into a PKCS12
|
| 176 | keystore using OpenSSL you would execute a command like:
|
| 177 | <div align="left"><table cellspacing="4" cellpadding="0" border="0"><tr><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr><tr><td bgcolor="#023264" width="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#ffffff" height="1"><pre>openssl pkcs12 -export -in mycert.crt -inkey mykey.key \
|
| 178 | -out mycert.p12 -name tomcat -CAfile myCA.crt \
|
| 179 | -caname root -chain
|
| 180 | </pre></td><td bgcolor="#023264" width="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr><tr><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr></table></div>
|
| 181 | For more advanced cases, consult the <a href="http://www.openssl.org/">OpenSSL
|
| 182 | documentation</a>.
|
| 183 | </p>
|
| 184 | <p>To create a new keystore from scratch, containing a single self-signed
|
| 185 | Certificate, execute the following from a terminal command line:</p>
|
| 186 | <p>Windows:</p>
|
| 187 | <div align="left"><table cellspacing="4" cellpadding="0" border="0"><tr><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr><tr><td bgcolor="#023264" width="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#ffffff" height="1"><pre>
|
| 188 | %JAVA_HOME%\bin\keytool -genkey -alias tomcat -keyalg RSA
|
| 189 | </pre></td><td bgcolor="#023264" width="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr><tr><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr></table></div>
|
| 190 | <p>Unix:</p>
|
| 191 | <div align="left"><table cellspacing="4" cellpadding="0" border="0"><tr><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr><tr><td bgcolor="#023264" width="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#ffffff" height="1"><pre>
|
| 192 | $JAVA_HOME/bin/keytool -genkey -alias tomcat -keyalg RSA
|
| 193 | </pre></td><td bgcolor="#023264" width="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr><tr><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr></table></div>
|
| 194 |
|
| 195 | <p>(The RSA algorithm should be preferred as a secure algorithm, and this
|
| 196 | also ensures general compatibility with other servers and components.)</p>
|
| 197 |
|
| 198 | <p>This command will create a new file, in the home directory of the user
|
| 199 | under which you run it, named "<code>.keystore</code>". To specify a
|
| 200 | different location or filename, add the <code>-keystore</code> parameter,
|
| 201 | followed by the complete pathname to your keystore file,
|
| 202 | to the <code>keytool</code> command shown above. You will also need to
|
| 203 | reflect this new location in the <code>server.xml</code> configuration file,
|
| 204 | as described later. For example:</p>
|
| 205 | <p>Windows:</p>
|
| 206 | <div align="left"><table cellspacing="4" cellpadding="0" border="0"><tr><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr><tr><td bgcolor="#023264" width="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#ffffff" height="1"><pre>
|
| 207 | %JAVA_HOME%\bin\keytool -genkey -alias tomcat -keyalg RSA \
|
| 208 | -keystore \path\to\my\keystore
|
| 209 | </pre></td><td bgcolor="#023264" width="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr><tr><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr></table></div>
|
| 210 | <p>Unix:</p>
|
| 211 | <div align="left"><table cellspacing="4" cellpadding="0" border="0"><tr><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr><tr><td bgcolor="#023264" width="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#ffffff" height="1"><pre>
|
| 212 | $JAVA_HOME/bin/keytool -genkey -alias tomcat -keyalg RSA \
|
| 213 | -keystore /path/to/my/keystore
|
| 214 | </pre></td><td bgcolor="#023264" width="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr><tr><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr></table></div>
|
| 215 |
|
| 216 | <p>After executing this command, you will first be prompted for the keystore
|
| 217 | password. The default password used by Tomcat is "<code>changeit</code>"
|
| 218 | (all lower case), although you can specify a custom password if you like.
|
| 219 | You will also need to specify the custom password in the
|
| 220 | <code>server.xml</code> configuration file, as described later.</p>
|
| 221 |
|
| 222 | <p>Next, you will be prompted for general information about this Certificate,
|
| 223 | such as company, contact name, and so on. This information will be displayed
|
| 224 | to users who attempt to access a secure page in your application, so make
|
| 225 | sure that the information provided here matches what they will expect.</p>
|
| 226 |
|
| 227 | <p>Finally, you will be prompted for the <em>key password</em>, which is the
|
| 228 | password specifically for this Certificate (as opposed to any other
|
| 229 | Certificates stored in the same keystore file). You <strong>MUST</strong>
|
| 230 | use the same password here as was used for the keystore password itself.
|
| 231 | This is a restriction of the Tomcat implementation.
|
| 232 | (Currently, the <code>keytool</code> prompt will tell you that pressing the
|
| 233 | ENTER key does this for you automatically.)</p>
|
| 234 |
|
| 235 | <p>If everything was successful, you now have a keystore file with a
|
| 236 | Certificate that can be used by your server.</p>
|
| 237 |
|
| 238 | <p><strong>Note:</strong> your private key password and keystore password
|
| 239 | should be the same. If they differ, you will get an error along the lines
|
| 240 | of <code>java.io.IOException: Cannot recover key</code>, as documented in
|
| 241 | <a href="http://issues.apache.org/bugzilla/show_bug.cgi?id=38217">Bugzilla issue 38217</a>,
|
| 242 | which contains further references for this issue.</p>
|
| 243 |
|
| 244 | </blockquote></td></tr></table>
|
| 245 |
|
| 246 | <table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#828DA6"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Edit the Tomcat Configuration File"><!--()--></a><a name="Edit_the_Tomcat_Configuration_File"><strong>Edit the Tomcat Configuration File</strong></a></font></td></tr><tr><td><blockquote>
|
| 247 | <p>
|
| 248 | Tomcat can use two different implementations of SSL:
|
| 249 | <ul>
|
| 250 | <li>the JSSE implementation provided as part of the Java runtime (since 1.4)</li>
|
| 251 | <li>the APR implementation, which uses the OpenSSL engine by default.</li>
|
| 252 | </ul>
|
| 253 | The exact configuration details depend on which implementation is being used.
|
| 254 | The implementation used by Tomcat is chosen automatically unless it is overriden as described below.
|
| 255 | If the installation uses <a href="apr.html">APR</a>
|
| 256 | - i.e. you have installed the Tomcat native library -
|
| 257 | then it will use the APR SSL implementation, otherwise it will use the Java JSSE implementation.
|
| 258 | </p>
|
| 259 |
|
| 260 | <p>
|
| 261 | To avoid auto configuration you can define which implementation to use by specifying a classname
|
| 262 | in the <b>protocol</b> attribute of the Connector.<br>
|
| 263 | To define a Java (JSSE) connector, regardless of whether the APR library is loaded or not do:
|
| 264 | <div align="left"><table cellspacing="4" cellpadding="0" border="0"><tr><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr><tr><td bgcolor="#023264" width="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#ffffff" height="1"><pre>
|
| 265 | <-- Define a blocking Java SSL Coyote HTTP/1.1 Connector on port 8443 -->
|
| 266 | <Connector protocol="org.apache.coyote.http11.Http11Protocol"
|
| 267 | port="8443" .../>
|
| 268 |
|
| 269 | <-- Define a non-blocking Java SSL Coyote HTTP/1.1 Connector on port 8443 -->
|
| 270 | <Connector protocol="org.apache.coyote.http11.Http11NioProtocol"
|
| 271 | port="8443" .../>
|
| 272 | </pre></td><td bgcolor="#023264" width="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr><tr><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr></table></div>
|
| 273 | Alternatively, to specify an APR connector (the APR library must be available) use:
|
| 274 | <div align="left"><table cellspacing="4" cellpadding="0" border="0"><tr><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr><tr><td bgcolor="#023264" width="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#ffffff" height="1"><pre>
|
| 275 | <-- Define a APR SSL Coyote HTTP/1.1 Connector on port 8443 -->
|
| 276 | <Connector protocol="org.apache.coyote.http11.Http11AprProtocol"
|
| 277 | port="8443" .../>
|
| 278 | </pre></td><td bgcolor="#023264" width="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr><tr><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr></table></div>
|
| 279 |
|
| 280 | </p>
|
| 281 |
|
| 282 | <p>If you are using APR, you have the option of configuring an alternative engine to OpenSSL.
|
| 283 | <div align="left"><table cellspacing="4" cellpadding="0" border="0"><tr><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr><tr><td bgcolor="#023264" width="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#ffffff" height="1"><pre>
|
| 284 | <Listener className="org.apache.catalina.core.AprLifecycleListener"
|
| 285 | SSLEngine="someengine" SSLRandomSeed="somedevice" />
|
| 286 | </pre></td><td bgcolor="#023264" width="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr><tr><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr></table></div>
|
| 287 | The default value is
|
| 288 | <div align="left"><table cellspacing="4" cellpadding="0" border="0"><tr><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr><tr><td bgcolor="#023264" width="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#ffffff" height="1"><pre>
|
| 289 | <Listener className="org.apache.catalina.core.AprLifecycleListener"
|
| 290 | SSLEngine="on" SSLRandomSeed="builtin" />
|
| 291 | </pre></td><td bgcolor="#023264" width="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr><tr><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr></table></div>
|
| 292 | So to use SSL under APR, make sure the SSLEngine attribute is set to something other than <code>off</code>.
|
| 293 | The default value is <code>on</code> and if you specify another value, it has to be a valid engine name.
|
| 294 | <br>
|
| 295 | If you haven't compiled in SSL support into your Tomcat Native library, then you can turn this initialization off
|
| 296 | <div align="left"><table cellspacing="4" cellpadding="0" border="0"><tr><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr><tr><td bgcolor="#023264" width="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#ffffff" height="1"><pre>
|
| 297 | <Listener className="org.apache.catalina.core.AprLifecycleListener"
|
| 298 | SSLEngine="off" />
|
| 299 | </pre></td><td bgcolor="#023264" width="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr><tr><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr></table></div>
|
| 300 | SSLRandomSeed allows to specify a source of entropy. Productive system needs a reliable source of entropy
|
| 301 | but entropy may need a lot of time to be collected therefore test systems could use no blocking entropy
|
| 302 | sources like "/dev/urandom" that will allow quicker starts of Tomcat.
|
| 303 |
|
| 304 | </p>
|
| 305 |
|
| 306 | <p>The final step is to configure the Connector in the
|
| 307 | <code>$CATALINA_BASE/conf/server.xml</code> file, where
|
| 308 | <code>$CATALINA_BASE</code> represents the base directory for the
|
| 309 | Tomcat 6 instance. An example <code><Connector></code> element
|
| 310 | for an SSL connector is included in the default <code>server.xml</code>
|
| 311 | file installed with Tomcat. For JSSE, it should look something like this:</p>
|
| 312 | <div align="left"><table cellspacing="4" cellpadding="0" border="0"><tr><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr><tr><td bgcolor="#023264" width="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#ffffff" height="1"><pre>
|
| 313 | <-- Define a SSL Coyote HTTP/1.1 Connector on port 8443 -->
|
| 314 | <!--
|
| 315 | <Connector
|
| 316 | port="8443" maxThreads="200"
|
| 317 | scheme="https" secure="true" SSLEnabled="true"
|
| 318 | keystoreFile="${user.home}/.keystore" keystorePass="changeit"
|
| 319 | clientAuth="false" sslProtocol="TLS"/>
|
| 320 | -->
|
| 321 | </pre></td><td bgcolor="#023264" width="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr><tr><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr></table></div>
|
| 322 | <p>
|
| 323 | The example above will throw an error if you have the APR and the Tomcat Native libraries in your path,
|
| 324 | as Tomcat will try to use the APR connector. The APR connector uses different attributes for
|
| 325 | SSL keys and certificates. An example of an APR configuration is:
|
| 326 | <div align="left"><table cellspacing="4" cellpadding="0" border="0"><tr><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr><tr><td bgcolor="#023264" width="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#ffffff" height="1"><pre>
|
| 327 | <-- Define a SSL Coyote HTTP/1.1 Connector on port 8443 -->
|
| 328 | <!--
|
| 329 | <Connector
|
| 330 | port="8443" maxThreads="200"
|
| 331 | scheme="https" secure="true" SSLEnabled="true"
|
| 332 | SSLCertificateFile="/usr/local/ssl/server.crt"
|
| 333 | SSLCertificateKeyFile="/usr/local/ssl/server.pem"
|
| 334 | clientAuth="optional" SSLProtocol="TLSv1"/>
|
| 335 | -->
|
| 336 | </pre></td><td bgcolor="#023264" width="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr><tr><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr></table></div>
|
| 337 | </p>
|
| 338 |
|
| 339 | <p>You will note that the example SSL connector elements are commented out by
|
| 340 | default. You can either remove the comment tags from around the the example SSL
|
| 341 | connector you wish to use or add a new Connector element of your own. In either
|
| 342 | case, you will need to configure the SSL Connector for your requirements
|
| 343 | and environment. The configuration options and information on which attributes
|
| 344 | are mandatory for the JSSE based connectors (BIO and NIO) are documented in the
|
| 345 | SSL Support section of the <a href="config/http.html#SSL Support">HTTP
|
| 346 | connector</a> configuration reference. The configuration options and information
|
| 347 | on which attributes are mandatory for the APR connector are documented in the
|
| 348 | HTTPS section of the <a href="apr.html#HTTPS">APR How-To</a>.</p>
|
| 349 |
|
| 350 | <p>The <code>port</code> attribute (default value is 8443) is the TCP/IP
|
| 351 | port number on which Tomcat will listen for secure connections. You can
|
| 352 | change this to any port number you wish (such as to the default port for
|
| 353 | <code>https</code> communications, which is 443). However, special setup
|
| 354 | (outside the scope of this document) is necessary to run Tomcat on port
|
| 355 | numbers lower than 1024 on many operating systems.</p>
|
| 356 |
|
| 357 | <blockquote><em>
|
| 358 | <p>If you change the port number here, you should also change the
|
| 359 | value specified for the <code>redirectPort</code> attribute on the
|
| 360 | non-SSL connector. This allows Tomcat to automatically redirect
|
| 361 | users who attempt to access a page with a security constraint specifying
|
| 362 | that SSL is required, as required by the Servlet Specification.</p>
|
| 363 | </em></blockquote>
|
| 364 |
|
| 365 | <p>After completing these configuration changes, you must restart Tomcat as
|
| 366 | you normally do, and you should be in business. You should be able to access
|
| 367 | any web application supported by Tomcat via SSL. For example, try:</p>
|
| 368 | <div align="left"><table cellspacing="4" cellpadding="0" border="0"><tr><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr><tr><td bgcolor="#023264" width="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#ffffff" height="1"><pre>
|
| 369 | https://localhost:8443
|
| 370 | </pre></td><td bgcolor="#023264" width="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr><tr><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr></table></div>
|
| 371 |
|
| 372 | <p>and you should see the usual Tomcat splash page (unless you have modified
|
| 373 | the ROOT web application). If this does not work, the following section
|
| 374 | contains some troubleshooting tips.</p>
|
| 375 |
|
| 376 | </blockquote></td></tr></table>
|
| 377 |
|
| 378 | </blockquote></td></tr></table><table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Installing a Certificate from a Certificate Authority"><!--()--></a><a name="Installing_a_Certificate_from_a_Certificate_Authority"><strong>Installing a Certificate from a Certificate Authority</strong></a></font></td></tr><tr><td><blockquote>
|
| 379 | <p>To obtain and install a Certificate from a Certificate Authority (like verisign.com, thawte.com
|
| 380 | or trustcenter.de), read the previous section and then follow these instructions:</p>
|
| 381 |
|
| 382 | <table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#828DA6"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Create a local Certificate Signing Request (CSR)"><!--()--></a><a name="Create_a_local_Certificate_Signing_Request_(CSR)"><strong>Create a local Certificate Signing Request (CSR)</strong></a></font></td></tr><tr><td><blockquote>
|
| 383 | <p>In order to obtain a Certificate from the Certificate Authority of your choice
|
| 384 | you have to create a so called Certificate Signing Request (CSR). That CSR will be used
|
| 385 | by the Certificate Authority to create a Certificate that will identify your website
|
| 386 | as "secure". To create a CSR follow these steps:</p>
|
| 387 | <ul>
|
| 388 | <li>Create a local Certificate (as described in the previous section):
|
| 389 | <div align="left"><table cellspacing="4" cellpadding="0" border="0"><tr><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr><tr><td bgcolor="#023264" width="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#ffffff" height="1"><pre>keytool -genkey -alias tomcat -keyalg RSA \
|
| 390 | -keystore <your_keystore_filename></pre></td><td bgcolor="#023264" width="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr><tr><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr></table></div>
|
| 391 | Note: In some cases you will have to enter the domain of your website (i.e. <code>www.myside.org</code>)
|
| 392 | in the field "first- and lastname" in order to create a working Certificate.
|
| 393 | </li>
|
| 394 | <li>The CSR is then created with:
|
| 395 | <div align="left"><table cellspacing="4" cellpadding="0" border="0"><tr><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr><tr><td bgcolor="#023264" width="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#ffffff" height="1"><pre>keytool -certreq -keyalg RSA -alias tomcat -file certreq.csr \
|
| 396 | -keystore <your_keystore_filename></pre></td><td bgcolor="#023264" width="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr><tr><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr></table></div>
|
| 397 | </li>
|
| 398 | </ul>
|
| 399 | <p>Now you have a file called <code>certreq.csr</code> that you can submit to the Certificate Authority (look at the
|
| 400 | documentation of the Certificate Authority website on how to do this). In return you get a Certificate.</p>
|
| 401 | </blockquote></td></tr></table>
|
| 402 |
|
| 403 | <table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#828DA6"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Importing the Certificate"><!--()--></a><a name="Importing_the_Certificate"><strong>Importing the Certificate</strong></a></font></td></tr><tr><td><blockquote>
|
| 404 | <p>Now that you have your Certificate you can import it into you local keystore.
|
| 405 | First of all you have to import a so called Chain Certificate or Root Certificate into your keystore.
|
| 406 | After that you can proceed with importing your Certificate.</p>
|
| 407 |
|
| 408 | <ul>
|
| 409 | <li>Download a Chain Certificate from the Certificate Authority you obtained the Certificate from.<br>
|
| 410 | For Verisign.com commercial certificates go to:
|
| 411 | http://www.verisign.com/support/install/intermediate.html<br>
|
| 412 | For Verisign.com trial certificates go to:
|
| 413 | http://www.verisign.com/support/verisign-intermediate-ca/Trial_Secure_Server_Root/index.html<br>
|
| 414 | For Trustcenter.de go to:
|
| 415 | http://www.trustcenter.de/certservices/cacerts/en/en.htm#server<br>
|
| 416 | For Thawte.com go to:
|
| 417 | http://www.thawte.com/certs/trustmap.html<br>
|
| 418 | </li>
|
| 419 | <li>Import the Chain Certificate into your keystore
|
| 420 | <div align="left"><table cellspacing="4" cellpadding="0" border="0"><tr><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr><tr><td bgcolor="#023264" width="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#ffffff" height="1"><pre>keytool -import -alias root -keystore <your_keystore_filename> \
|
| 421 | -trustcacerts -file <filename_of_the_chain_certificate></pre></td><td bgcolor="#023264" width="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr><tr><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr></table></div>
|
| 422 | </li>
|
| 423 | <li>And finally import your new Certificate
|
| 424 | <div align="left"><table cellspacing="4" cellpadding="0" border="0"><tr><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr><tr><td bgcolor="#023264" width="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#ffffff" height="1"><pre>keytool -import -alias tomcat -keystore <your_keystore_filename> \
|
| 425 | -file <your_certificate_filename></pre></td><td bgcolor="#023264" width="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr><tr><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td><td bgcolor="#023264" width="1" height="1"><img src="./images/void.gif" alt="" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr></table></div>
|
| 426 | </li>
|
| 427 | </ul>
|
| 428 | </blockquote></td></tr></table>
|
| 429 | </blockquote></td></tr></table><table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Troubleshooting"><strong>Troubleshooting</strong></a></font></td></tr><tr><td><blockquote>
|
| 430 |
|
| 431 | <p>Here is a list of common problems that you may encounter when setting up
|
| 432 | SSL communications, and what to do about them.</p>
|
| 433 |
|
| 434 | <ul>
|
| 435 |
|
| 436 | <li>When Tomcat starts up, I get an exception like
|
| 437 | "java.io.FileNotFoundException: {some-directory}/{some-file} not found".
|
| 438 | <blockquote>
|
| 439 | <p>A likely explanation is that Tomcat cannot find the keystore file
|
| 440 | where it is looking. By default, Tomcat expects the keystore file to
|
| 441 | be named <code>.keystore</code> in the user home directory under which
|
| 442 | Tomcat is running (which may or may not be the same as yours :-). If
|
| 443 | the keystore file is anywhere else, you will need to add a
|
| 444 | <code>keystoreFile</code> attribute to the <code><Factory></code>
|
| 445 | element in the <a href="#Edit the Tomcat Configuration File">Tomcat
|
| 446 | configuration file</a>.</p>
|
| 447 | </blockquote></li>
|
| 448 |
|
| 449 | <li>When Tomcat starts up, I get an exception like
|
| 450 | "java.io.FileNotFoundException: Keystore was tampered with, or
|
| 451 | password was incorrect".
|
| 452 | <blockquote>
|
| 453 | <p>Assuming that someone has not <em>actually</em> tampered with
|
| 454 | your keystore file, the most likely cause is that Tomcat is using
|
| 455 | a different password than the one you used when you created the
|
| 456 | keystore file. To fix this, you can either go back and
|
| 457 | <a href="#Prepare the Certificate Keystore">recreate the keystore
|
| 458 | file</a>, or you can add or update the <code>keystorePass</code>
|
| 459 | attribute on the <code><Connector></code> element in the
|
| 460 | <a href="#Edit the Tomcat Configuration File">Tomcat configuration
|
| 461 | file</a>. <strong>REMINDER</strong> - Passwords are case sensitive!</p>
|
| 462 | </blockquote></li>
|
| 463 |
|
| 464 | <li>When Tomcat starts up, I get an exception like
|
| 465 | "java.net.SocketException: SSL handshake errorjavax.net.ssl.SSLException: No
|
| 466 | available certificate or key corresponds to the SSL cipher suites which are
|
| 467 | enabled."
|
| 468 | <blockquote>
|
| 469 | <p>A likely explanation is that Tomcat cannot find the alias for the server
|
| 470 | key within the specified keystore. Check that the correct
|
| 471 | <code>keystoreFile</code> and <code>keyAlias</code> are specified in the
|
| 472 | <code><Connector></code> element in the
|
| 473 | <a href="#Edit the Tomcat Configuration File">Tomcat configuration file</a>.
|
| 474 | <strong>REMINDER</strong> - <code>keyAlias</code> values may be case
|
| 475 | sensitive!</p>
|
| 476 | </blockquote></li>
|
| 477 |
|
| 478 | </ul>
|
| 479 |
|
| 480 | <p>If you are still having problems, a good source of information is the
|
| 481 | <strong>TOMCAT-USER</strong> mailing list. You can find pointers to archives
|
| 482 | of previous messages on this list, as well as subscription and unsubscription
|
| 483 | information, at
|
| 484 | <a href="http://tomcat.apache.org/lists.html">http://tomcat.apache.org/lists.html</a>.</p>
|
| 485 |
|
| 486 | </blockquote></td></tr></table><table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Miscellaneous Tips and Bits"><!--()--></a><a name="Miscellaneous_Tips_and_Bits"><strong>Miscellaneous Tips and Bits</strong></a></font></td></tr><tr><td><blockquote>
|
| 487 |
|
| 488 | <p>To access the SSL session ID from the request, use:<br>
|
| 489 |
|
| 490 | <code>
|
| 491 | String sslID = (String)request.getAttribute("javax.servlet.request.ssl_session");
|
| 492 | </code>
|
| 493 | <br>
|
| 494 | For additional discussion on this area, please see
|
| 495 | <a href="http://issues.apache.org/bugzilla/show_bug.cgi?id=22679">Bugzilla</a>.
|
| 496 | </p>
|
| 497 |
|
| 498 | </blockquote></td></tr></table></td></tr><!--FOOTER SEPARATOR--><tr><td colspan="2"><hr noshade="noshade" size="1"></td></tr><!--PAGE FOOTER--><tr><td colspan="2"><div align="center"><font color="#525D76" size="-1"><em>
|
| 499 | Copyright © 1999-2014, Apache Software Foundation
|
| 500 | </em></font></div></td></tr></table></body></html> |