【发布时间】:2012-07-30 15:35:51
【问题描述】:
我有一个在 http 上运行的应用程序,然后我尝试通过 https 创建登录页面。早期的 apache web server 用于通过 ajp 协议将请求转发给注册 worker 的 tomcat。现在我在/etc/apache2/crt中添加了一个密钥和证书,即ssl.key,ssl.crt。其中还有一个certificate.csr 文件。用于生成上述证书的命令来自http://www.akadia.com/services/ssh_test_certificate.html,因为/etc/apache2/sites-available 中有两个文件:default 和default-ssl,所以我还没有完成第6 步。我在default-ssl 中更改了两行:
SSLCertificateFile /etc/apache2/crt/certificate.csr
SSLCertificateKeyFile /etc/apache2/crt/ssl.key
我还更改了 tomcat 的 server.xml 以在 8446 后接收 https:
<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"/>
我还更改了web.xml,现在它还包含:
<security-constraint>
<web-resource-collection>
<web-resource-name>Secure Login</web-resource-name>
<url-pattern>/login/*</url-pattern>
<!-- <url-pattern>/other/secure/stuff/*</url-pattern> -->
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
我尝试了curl -Iv https://localhost 和curl -Iv https://localhost:8446,但出现以下错误:
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
请告诉我如何实现这一目标。
【问题讨论】:
-
部分工作的答案:sudo a2ensite default-ssl 和使用 ssl.crt 现在 Apache 在 443 端口听到。我希望它把它转发给 tomcat...尝试它..
标签: spring apache tomcat https