Tomcat 5.5: Configure One-way SSL Instruction

Abstract:

This instruction will guide you how to configure one-way SSL in tomcat 5.5

Instruction:

Step1: Running keytool

Open cmd and execute following command.

keytool -genkey -alias tomcat -keyalg RSA -keypass yourpassword -storepass yourpassword -keystore C:/Tomcat55/keystore -validity 3600

Parameters:

-alias: Indicate a name which identify a entry in a keystore

-keyalg: Indicate encryption algorithm (Recommendation: RSA)

-keypass: Replace this param by your password.

-storepass: Replace this param by keypass password.

-keystore: The location where your store keystore file.

-validity: Indicate how many days will be valid for this keystore. (Default is 90 days.)

Step2: Config keytool

Complete following parameter as shown.

您的名字与姓氏是什么?
  [Unknown]:  localhost   (Fill this blank with your granted domain or any others as testing)
您的组织单位名称是什么?
  [Unknown]:  Personal Testing.    (Any String is OK.)
您的组织名称是什么?
  [Unknown]:  Personal Testing.    (Any String is OK.)
您所在的城市或区域名称是什么?
  [Unknown]:  Beijing                     (Your city.)
您所在的州或省份名称是什么?
  [Unknown]:  Beijing                     (Your state.)
该单位的两字母国家代码是什么
  [Unknown]:  CN                           (Your country code.)
CN=localhost, OU=Personal Testing., O=Personal Testing., L=Beijing, ST=Beijing,
C=CN 正确吗?
  [否]:  y                                         (Enter with ‘Y’ if everything is fine.)

After above, you should able to see a file named ‘keystore’ in C:/Tomcat55.

Step3: Config Server.xml

Open server.xml from C:/Tomcat55/conf. Then edit related configuration as below.

   
 
<Connector port="80" maxHttpHeaderSize="8192"
           maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
           enableLookups="false" redirectPort="443" acceptCount="100"
           connectionTimeout="20000" disableUploadTimeout="true" />
 

Notice: change your port number as 80 instead of 8080 and change redirectPort as 443.

 
    
<Connector port="443" maxHttpHeaderSize="8192"
           maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
           enableLookups="false" disableUploadTimeout="true"
           acceptCount="100" scheme="https" secure="true"
           clientAuth="false" sslProtocol="TLS" 
           keystoreFile="keystore" keystorePass="yourpassword"/>

Notice: change your port number as 443 instead of 8443. And keystoreFile should be the location where your store keystore file. keystorePass should be same as what you specify in keytool command.

<Connector port="8009" 
           enableLookups="false" redirectPort="443" protocol="AJP/1.3" />

Notice: change redirectPort as 443.

Save and quit.

Step4: Config web.xml

Open web.xml from same directory. And add following additional parameter to the end of the file.

<security-constraint>
    <web-resource-collection >
        <web-resource-name >SSL</web-resource-name>
        <url-pattern>/*</url-pattern>
    </web-resource-collection>
    <user-data-constraint>
        <transport-guarantee>CONFIDENTIAL</transport-guarantee>
    </user-data-constraint>
</security-constraint>

Save and quit.

 

Step5: Testing

Startup Tomcat server.

If everything is fine, you should able to access https://localhost or http://localhost.

 

Additionally, may be you have to add following attribute to the <connector> definition.

protocol="org.apache.coyote.http11.Http11Protocol"  

That will be work at 5.5.30.

 

For any question, please contact me.

[email protected]

你可能感兴趣的:(Tomcat 5.5: Configure One-way SSL Instruction)