title: Setting Up HTTPS for JBoss 5.1.0 GA
body: <p>I am in the process of moving my app from HTTP to HTTPS and seem to be running into an issue.</p>
  
  <p>Here is what I have done so far based off of <a href="https://wiki.jasig.org/display/CASUM/HOWTO+Configure+JBoss+for+HTTPS" rel="nofollow">these instructions</a>:</p>
  
  <ol>
  <li>Identify the hostname for the computer hosting the server.  I.e.: localhost for these instructions</li>
  <li>Identify the jBoss server type (all,default, production).  I.e.: ecotrak for these instructions</li>
  <li>jBoss recommends using the same file as both keystore and trustore.  This will be server.keystore.  In a virgin install there should be no server.keystore in thedefault/conf folder.  If you have one, you must decide whether to delete it (to use these instructions) or whether to adapt the instructions to suit your situation. </li>
  <li>Creating the keystore and private key: 
  <ul>
  <li>Open a command prompt or shell and go to the default/conf folder.</li>
  <li>keytool -genkey -alias jbosskey -keypass changeit -keyalg RSA -keystore server.keystore </li>
  <li>Answer the prompts.  Use myHostname when asked for first/last name.  This is critical. </li>
  <li>server.keystore is generated. </li>
  <li>keytool -list -keystore server.keystore </li>
  <li>You should see the PrivateKeyEntry named jbosskey in the listing.</li>
  </ul></li>
  <li>Generating and storing the certificate. 
  <ul>
  <li>keytool -export -alias jbosskey -keypass changeit -file server.crt -keystore server.keystore </li>
  <li>server.crt is generated. </li>
  <li>keytool -import -alias jbosscert -keypass changeit -file server.crt -keystore server.keystore </li>
  <li>You receive a warning that it already exists in the keystore.  Ignore it.  It is because Java expects separate keystore adn trustore files and we are using only one. </li>
  <li>keytool -list -keystore server.keystore </li>
  <li>You should see a TrustedCertEntry named jbosscert in the listing.</li>
  </ul></li>
  </ol>
  
  <p>In my server.xml I have the following:</p>
  
  <pre><code>  &lt;!-- SSL/TLS Connector configuration using the admin devl guide keystore--&gt;
    &lt;Connector protocol="HTTP/1.1" SSLEnabled="true" 
         port="8443" address="${jboss.bind.address}"
         scheme="https" secure="true" clientAuth="false" 
         keystoreFile="C:/dev/server/jboss-5.1.0.GA/server/ecotrak/conf/server.keystore"
         keystorePass="password" sslProtocol = "TLS" keyAlias="jbosskey" /&gt;
  </code></pre>
  
  <p>When I start the server I have the following:</p>
  
  <pre><code> call %JBOSS_HOME%\bin\run.bat -c default -b 0.0.0.0 -Djavax.net.ssl.trustStore=C:/dev/server/jboss-5.1.0.GA/server/ecotrak/conf/server.keystore
  </code></pre>
  
  <p>Here is what I get in my log file:</p>
  
  <pre><code>00:09:03,110 INFO [AprLifecycleListener] The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\dev\jdk\bin;.;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\dev\jdk\jre\bin;native
  
  00:09:03,197 INFO [Http11Protocol] Initializing Coyote HTTP/1.1 on http-localhost%2F127.0.0.1-8080
  
  00:09:03,214 INFO [AjpProtocol] Initializing Coyote AJP/1.3 on ajp-localhost%2F127.0.0.1-8009
  
  00:09:03,261 ERROR [Http11Protocol] Error initializing endpoint
  
  java.io.IOException: Cannot recover key
  
  at org.apache.tomcat.util.net.jsse.JSSESocketFactory.init(JSSESocketFactory.java:456)
  
  at org.apache.tomcat.util.net.jsse.JSSESocketFactory.createSocket(JSSESocketFactory.java:139)
  </code></pre>
  
  <p>Another section of the log</p>
  
  <pre><code>00:09:03,265 ERROR [AbstractKernelController] Error installing to Start: name=WebServer state=Create
  
  LifecycleException: Protocol handler initialization failed: java.io.IOException: Cannot recover key
  
  at org.apache.catalina.connector.Connector.initialize(Connector.java:1031)
  
  at org.apache.catalina.core.StandardService.initialize(StandardService.java:683)
  </code></pre>
  
  <p>DEPLOYMENTS IN ERROR:</p>
  
  <pre><code>Deployment "WebServer" is in error due to the following reason(s): LifecycleException: Protocol handler initialization failed: java.io.IOException: Cannot recover key
  
  Deployment "jboss.web:service=WebServer" is in error due to the following reason(s): ** NOT FOUND Depends on 'jboss.web:service=WebServer' **
  </code></pre>
  
  <p>Any ideal as to what is going on here?</p>
  
  <hr>
  
  <p><strong>Update</strong></p>
  
  <p>I found my error - I had mixed up the passwords between the keystore and the cert.  Once that was fixed I am now able to run the site under HTTPS</p>