开发者

Tomcat6 configured to use SSL does not work

I am trying to setup SSL to my web app and followed tutorial (http://techtracer.com/2007/09/12/setting-up-ssl-on-tomcat-in-3-easy-steps/), then hitting http://localhost:8443 returns "unable to connect"

Environment:

Tomcat6, windows 7

Tomcat6 is up and running, http://localhost:8080 displays tomcat page.

Below is the step I took so far:

1. Generate keystore file

C:\Program Files\Java\jdk1.6.0_21\bin>keytool -genkey -alias masatosanssl -keypass mas开发者_如何学Catosanadmin -keystore masatosanssl.bin -storepass
 masatosanadmin

then I answered the questionnaire.

masatosanssl.bin is created and I've moved the file to my webapp dir which is at:

C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\head_first\masatosanssl.bin

2. Configuring Tomcat for using the Keystore file

Modify server.xml

Location: C:\Program Files\Apache Software Foundation\Tomcat 6.0\conf

<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
        maxThreads="150" scheme="https" secure="true"
        clientAuth="false" sslProtocol="TLS" 
        keystoreFile="C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\head_first\masatosanssl.bin"
        keystorePass="masatosanadmin" 
               />

Then I restart tomcat and hit https://localhost:8443 returns "cannot display page", I've tried changing server.xml keystoreFile path to relative etc but none seems to work.

What am I missing here?


You are not missing anything except checking the logs. I had the same issue and almost checked everywhere over internet. I was trying to run the web service over tomcat 7.0 and generated the keystore the same way you did. The issue as Apache documentation for running over ssl says is that if any setting or jar file regarding APR implementation of SSL keys is in tomcat directory, it assumes you are using openssl and not JSSE implementation which can work with keystores generated by keytool. To localize the source of the problem, I looked at server.xml file in [tomcat dir]/conf and I saw this line was there:

<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />

Then I commented out this line and restart the server. It works now like a charm!

I found the source of error by reading apache docs carefully in addition to looking into the logs. It is always a good practice


Did you check Tomcat's logs? Failures to start a Connector will typically generate log messages describing exactly why it could not be started.

What does "returns 'cannot display page'" mean? Is the server listening on the port or not? What does curl -I http://localhost:8443/ or telnet localhost 8443 show?

And are you really sure you want to store your keypass file under a publically-accessible directory like webapps/head_first? Typically this file should be stored in a directory where only the user that Tomcat runs under can read it.


Try doing it the way described in the Tomcat documentation, not some arbitrary Internet junk.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜