Ubuntu – HTTPS not working on Tomcat 7

httpsssltomcattomcat7Ubuntu

I am trying to add ssl configuration in tomcat 7 in ubuntu 11.10 but it is not working and there are no errors in logs.
I added in server.xml this:

<Connector port="8443"  protocol="HTTP/1.1" SSLEnabled="true" maxHttpHeaderSize="8192"
           maxThreads="150" minSpareThreads="25"
           enableLookups="false" disableUploadTimeout="true"
           acceptCount="100" scheme="https" secure="true"
           keystoreFile="mycertificate.cert"
           keystorePass="mypass"
       clientAuth="false" sslProtocol="TLS" />

I have also added in web.xml this:

<security-constraint>
<web-resource-collection>
<web-resource-name>Protected Context</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<!-- auth-constraint goes here if you requre authentication -->
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>

I have also tried other ports. I also tried redirect but nothing is working.

In catalina.out I get only this:

Feb 09, 2016 3:50:27 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8443"]
Feb 09, 2016 3:50:27 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 665 ms
Feb 09, 2016 3:50:27 PM org.apache.catalina.core.StandardService     startInternal
INFO: Starting service Catalina
Feb 09, 2016 3:50:27 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.21
Feb 09, 2016 3:50:27 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory ROOT
Feb 09, 2016 3:51:20 PM org.apache.catalina.util.SessionIdGenerator createSecureRandom
INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [52,112] milliseconds.
Feb 09, 2016 3:51:20 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8443"]
Feb 09, 2016 3:51:20 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 52915 ms

In browser I get ERR_CONNECTION_TIMED_OUT

I also used curl -vlkL https://localhost:8081 –ciphers DHE-RSA-AES256-SHA

and it returns homepage of tomcat but it is not working in browser

Best Answer

Tomcat needs the certificate stored in a Java keystore. You however have set keystoreFile to a cert file.

You need to import your certificate into a JKS keystore and change the keystoreFile parameter to that file.

Java comes with keytool utility. The keytool programm covers everything you need to deal with JKS. Take a look at this website for the most common tasks.

Related Topic