Tag Archives: SSL Certificate

How to add ssl certificate (.crt) on tomcat server

Cek Version of Tomcat

#./version.sh
Using CATALINA_BASE:   /usr/local/apache-tomcat6.0
Using CATALINA_HOME:   /usr/local/apache-tomcat6.0
Using CATALINA_TMPDIR: /usr/local/apache-tomcat6.0/temp
Using JRE_HOME:       /usr/local/jdk1.6.0
Server version: Apache Tomcat/6.0.18
Server built:   Jul 22 2008 02:00:36
Server number:  6.0.18.0
OS Name:        FreeBSD
OS Version:     7.2-RELEASE
Architecture:   i386
JVM Version:    1.6.0_03-p4-yamaha_11_jul_2009_13_09-b00
JVM Vendor:     Sun Microsystems Inc.

Generate Key Pair and Generating a Certificate Signing Request (CSR)

#keytool -keysize 2048 -genkey -alias tomcat -keyalg RSA -keystore tomcat.keystore

#keytool -certreq -keyalg RSA -alias tomcat -file <your file name>.csr -keystore tomcat.keystore

download = valicert_class2_root.crt

https://certs.godaddy.com/anonymous/repository.seam;jsessionid=FFsaB0VCh4uykddhEW8H0A__.s2p02jb?streamfilename=valicert_class2_root.crt&actionMethod=anonymous%2Frepository.xhtml%3Arepository.streamFile%28%27%27%29&cid=359875

Installing Root and Intermediate Certificates

#keytool -import -alias root -keystore tomcat.keystore -trustcacerts -file valicert_class2_root.crt

#keytool -import -alias cross -keystore tomcat.keystore -trustcacerts -file gd_cross_intermediate.crt

#keytool -import -alias intermed -keystore tomcat.keystore -trustcacerts -file gd_intermediate.crt

Installing SSL Certificate

#keytool -import -alias tomcat -keystore tomcat.keystore -trustcacerts -file prigad.com.crt

Updating the server.xml Configuration File

#vi /usr/local/apache-tomcat6.0/conf/server.xml

<Connector port="9700" minSpareThreads="5" maxSpareThreads="75" enableLookups="true" disableUploadTimeout="true" acceptCount="100"  maxThreads="200" scheme="
https" secure="true" SSLEnabled="true" keystoreFile="/usr/home/kutukupret/ssl_2017/tomcat.keystore" keystorePass="passwordnya" clientAuth="false" sslProtocol="TLS"
/>

Restart  Tomcat

#cd /usr/local/apache-tomcat6.0/bin/

#./shutdown

#./startup

 

Add ssl certificate in tomcat 6

Yesterday I have added new ssl for my server. And this is step by step to setting this SSL.

Generating a Certificate Signing Request (CSR) – Tomcat 4.x/5.x/6.x

To Generate the Key Pair

  1. Enter the following command:
    keytool -keysize 2048 -genkey -alias tomcat -keyalg RSA -keystore tomcat.keystore
  2. You will be prompted for a password. Tomcat uses the default password changeit.
  3. Enter Distinguished Name (DN) information:
    • First and last name – This is the Common Name: The common name is the fully-qualified domain name (FQDN), Host name, or URL – to which you plan to apply your certificate. Do not enter your personal name in this field.

      NOTE: If you are requesting a Wildcard certificate, please add an asterisk (*) on the left side of the Common Name (e.g., "*.coolexample.com" or "www*.coolexample.com"). This will secure all subdomains of the Common Name.

    • Organizational unit – Use this field to differentiate between divisions within an organization. For example, "Engineering" or "Human Resources." If applicable, you may enter the DBA (doing business as) name in this field.
    • Organization – The name under which your business is legally registered. The listed organization must be the legal registrant of the domain name in the certificate request. If you are enrolling as an individual, please enter the certificate requestor's name in the Organization field, and the DBA (doing business as) name in the Organizational Unit field.
    • City/Locality – Name of the city in which your organization is registered/located. Please spell out the name of the city. Do not abbreviate.
    • State/Province – Name of state or province where your organization is located. Please enter the full name. Do not abbreviate.
    • Country code – The two-letter International Organization for Standardization- (ISO-) format country code for the country in which your organization is legally registered.
  4. Confirm that the Distinguished Name information is correct.

To Generate a CSR

  1. Enter the following command:
    keytool -certreq -keyalg RSA -alias tomcat -file <your file name>.csr -keystore tomcat.keystore
    
  2. Enter the keystore password:
    • If the password is correct then the CSR is created.
    • If the password is incorrect then a password error is displayed.
  3. Cut/copy and paste the generated CSR into our online enrollment form.
  4. Select Tomcat as your server software.

And than we should do this :

Installation Option One: Install the SSL Certificate and CA Bundle (gd_bundle.crt) Implementing a PKCS12 Keystore

Before you install your SSL certificate you must download our root certificate bundle (gd_bundle.crt) on your Web server. You may download the bundle from the repository.

Use the following OpenSSL command to combine the ca bundle gd_bundle.crt and your SSL certificate:

openssl pkcs12 -export -chain -CAfile gd_bundle.crt -in <name of your certificate> -inkey <name of your certificate private key file> -out keystore.tomcat -name tomcat -passout pass:changeit

Updating the server.xml Configuration File

When you have completed installing your certificate, you must configure your Tomcat server.xml configuration file to point to the correct pkcs12 keystore file:

  1. Open the server.xml file.
  2. After uncommenting the SSL/TLS connector from server.xml, locate the following Factory tag section and COMMENT IT OUT:
    <Factory className="org.apache.coyote.tomcat4.CoyoteServerSocketFactory" clientAuth="false" protocol="TLS" />
  3. Add the following directives to the Connector tag:
    keystoreFile=<path to>keystore.tomcat
    
    keystorePass="changeit"
    
    keystoreType="PKCS12"
  4. Restart Tomcat.

Installation Option Two: Install the SSL Certificate and Intermediate Certificate Separately

Installing Root and Intermediate Certificates

Once you have downloaded the certificates to your local machine, please use the following keytool commands to import them:

Root:

keytool -import -alias root -keystore tomcat.keystore -trustcacerts -file valicert_class2_root.crt

First intermediate (gd_cross_intermediate.crt):

keytool -import -alias cross -keystore tomcat.keystore -trustcacerts -file gd_cross_intermediate.crt

Second intermediate (gd_intermediate.crt):

keytool -import -alias intermed -keystore tomcat.keystore -trustcacerts -file gd_intermediate.crt

Installing SSL Certificate

Use the following command to import the issued certificate into your keystore.

keytool -import -alias tomcat -keystore tomcat.keystore -trustcacerts -file <name of your certificate>

Updating the server.xml Configuration File

When you have completed installing your certificate, you must configure your Tomcat server.xml configuration file to point to the correct keystore file:

  1. Open the server.xml file.
  2. After uncommenting the SSL/TLS connector from server.xml, locate the following text section:
    <Factory className="org.apache.coyote.tomcat4.CoyoteServerSocketFactory" clientAuth="false" protocol="TLS" />
  3. Add the "keystoreFile" and "keystorePass directives:
    <Factory className="org.apache.coyote.tomcat4.CoyoteServerSocketFactory" clientAuth="false" protocol="TLS" keystoreFile="/full/path/to/tomcat.keystore" keystorePass="changeit" />
  4. Restart Tomcat.

Sources =

http://help.godaddy.com/article/5239

http://help.godaddy.com/topic/742/article/5239