【发布时间】:2011-02-06 20:49:38
【问题描述】:
我主要关注这个页面:
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 文件中的行,则 webapp 可以正常工作。我在 /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”时出现问题(不确定我是否有这个问题或如何找出是否有)。但是我仍然遇到同样的错误。
【问题讨论】:
-
暂时不要添加安全约束。首先让 SSL 部分工作。
-
我删除了安全约束,没有任何改变,但我会在 SSL 正常工作之前将其关闭。顺便说一句,这里是我的整个 server.xml 文件的 pastebin,以防万一有帮助。它没有变化,除非我取消注释 SSL 部分。pastebin.com/yVRiNHi7
标签: ssl ubuntu ssl-certificate tomcat6