我主要参考了这个页面:
http://tomcat.apache.org/tomcat-6.0-doc/ssl-howto.html
我使用以下命令创建密钥库:
keytool -genkey -alias tomcat -keyalg RSA -keystore /etc/tomcat6/keystore
并回答提示的问题。
然后我编辑了我的server.xml文件,并取消注释/编辑了这一行:
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS"
keystoreFile="/etc/tomcat6/keystore"
keystorePass="tomcat" />
然后我进入我的项目的web.xml文件,并将其添加到文件中。
<security-constraint>
<web-resource-collection>
<web-resource-name>Security</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
当我尝试运行我的Web应用程序时,遇到了这个问题:
Unable to connect
Firefox can't establish a connection to the server at localhost:8443.
* The site could be temporarily unavailable or too busy. Try again in a few
moments.
* If you are unable to load any pages, check your computer's network
connection.
如果我注释掉我添加到web.xml文件的行,Web应用程序就可以正常工作。我的日志文件位于/var/lib/tomcat6/logs中,没有显示任何内容。我无法确定这是否是我的密钥库文件、server.xml文件或web.xml文件的问题…… 需要任何帮助。
我在Ubuntu上使用Tomcat 6。
编辑:我将我的server.xml更改为
<Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS"
keystoreFile="/etc/tomcat6/keystore"
keystorePass="tomcat" />
如果按照Tomcat教程建议,它被自动配置为"APR",可能会出现问题(我不确定我是否有这个配置,也不知道如何找到它)。然而,我仍然遇到了相同的错误。