title: Apache WebServer + Tomcat + Spring + Https
body: <p>I had an application running on http and then i tried to make the login page through https. Earlier apache web server used to forward request to tomcat who was a registered worker through ajp protocol. Now i added a key and certificate in <code>/etc/apache2/crt</code>, namely <code>ssl.key</code>, <code>ssl.crt</code>. There is also a <code>certificate.csr</code> file in that. The commands used for above certificate generation are from <a href="http://www.akadia.com/services/ssh_test_certificate.html" rel="nofollow">http://www.akadia.com/services/ssh_test_certificate.html</a> I haven't done step 6 since in <code>/etc/apache2/sites-available</code> there are two files: <code>default</code> and <code>default-ssl</code>. I changed two lines in <code>default-ssl</code> :</p>
  
  <pre><code>SSLCertificateFile    /etc/apache2/crt/certificate.csr
  SSLCertificateKeyFile /etc/apache2/crt/ssl.key
  </code></pre>
  
  <p>I also changed <code>server.xml</code> of tomcat to receive https at post 8446 :</p>
  
  <pre><code>&lt;Connector port="8446" protocol="HTTP/1.1" SSLEnabled="true"
            maxThreads="150" scheme="https" secure="true"
            clientAuth="false" sslProtocol="TLS" 
            keystoreFile="/etc/apache2/crt/ssl"
            keystorePass="password"/&gt;
  </code></pre>
  
  <p>I also changed <code>web.xml</code> and it now additionally contains:</p>
  
  <pre><code>&lt;security-constraint&gt;
      &lt;web-resource-collection&gt;
          &lt;web-resource-name&gt;Secure Login&lt;/web-resource-name&gt;
          &lt;url-pattern&gt;/login/*&lt;/url-pattern&gt;
       &lt;!--   &lt;url-pattern&gt;/other/secure/stuff/*&lt;/url-pattern&gt; --&gt;
      &lt;/web-resource-collection&gt;
      &lt;user-data-constraint&gt;
          &lt;transport-guarantee&gt;CONFIDENTIAL&lt;/transport-guarantee&gt;
      &lt;/user-data-constraint&gt;
  &lt;/security-constraint&gt;
  </code></pre>
  
  <p>I tried <code>curl -Iv https://localhost</code> and <code>curl -Iv https://localhost:8446</code> but the following error comes: </p>
  
  <pre><code>About to connect() to localhost port 8446 (#0)
  *   Trying 127.0.0.1... Connection refused
  * couldn't connect to host
  * Closing connection #0
  curl: (7) couldn't connect to host
  </code></pre>
  
  <p>Please let me know how to achieve this.</p>