Tuesday, January 7, 2014

Configuring Apache Tomcat with SSL Certificate

Refer post for Apache Tomcat Installation for installing the apache tomcat

If Apache Tomcat is already installed, Go to conf folder  and open the server.xml file

Go to section

<!-- A "Connector" represents an endpoint by which requests are received
         and responses are returned. Documentation at :
         Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
         Java AJP  Connector: /docs/config/ajp.html
         APR (HTTP/AJP) Connector: /docs/apr.html
         Define a non-SSL HTTP/1.1 Connector on port 8080
  -->   
<Connector port="8080" protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8443" /> 



Just comment the section as follows


<!-- A "Connector" represents an endpoint by which requests are received


         and responses are returned. Documentation at :


         Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)


         Java AJP  Connector: /docs/config/ajp.html


         APR (HTTP/AJP) Connector: /docs/apr.html


         Define a non-SSL HTTP/1.1 Connector on port 8080


    <Connector port="8080" protocol="HTTP/1.1"


               connectionTimeout="20000"


               redirectPort="8443" />


  -->  

Now go to section

<!-- 
Define a SSL HTTP/1.1 Connector on port 8443
         This connector uses the JSSE configuration, when using APR, the 
         connector should be using the OpenSSL style configuration
         described in the APR 
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
               maxThreads="150" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS" /> -->


And uncomment it as follows


<!-- Define a SSL HTTP/1.1 Connector on port 8443
         This connector uses the JSSE configuration, when using APR, the 
         connector should be using the OpenSSL style configuration
         described in the APR documentation   
 -->


 <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
               maxThreads="150" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS" />


Now copy the SSL certificate path and add to attributes keystoreFile and  keystorePass  in connector  tag for ssl

<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
               maxThreads="150" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS"
sslProtocol="TLS" 
keystoreFile="C:\Documents and Settings\Narendra\Desktop\testcsr\client.jks"
      keystorePass="test123" />

Deploy any web application and run the apache tomcat server
Now try accesing the web application using following URL



Click o Proceed anyway to accept the certificate
When you click on Lock near https in addres bar , following window appears . Click on certificate information , Certificate window will appear. As you can see, Issued to is example.com (the client) and Issued by is sspl.com which is the Certificate Authority .



0 comments:

Post a Comment