1.我想做什么
我目前正在创建一个动态web应用程序(JSP/Servlet),并尝试在Tomcat (v8.5)中设置SSL证书以从"https://[hostname]:8443/[AppName]"“访问。
2.当前问题
我无法访问"https://[hostname]:8443/[AppName]“页面,并显示以下消息。
The connection timeout.
the response from the localhost server was not received at a certain time.Cannot connect to my app using https
但不知何故,当我试图访问默认的Tomcat页面时,我可以通过"https://[hostname]:8443/“成功地访问它。
Can connect to Tomcat default using https
当然,我也可以使用"http“连接到我的应用程序,比如"http://[hostname]:8080/TennisDatabase”Can connect using http
3.我做了什么
(1)生成证书。
keytool -genkey -alias tomcat -keyalg RSA -keypass [password] -keystore mycertificate.cer -storepass [password](2)修改server.xml
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
scheme="https"
secure="true"
clientAuth="false"
sslProtocol="TLS"
sslEnabledProtocols="TLSv1.2,TLSv1.1,TLSv1"
keystoreFile="conf/mycertificate.cer" keystorePass="[password]" />(3)允许来自iptables的端口8443。
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8443 -j ACCEPT(4)Modify server.xml也将文件的权限修改为755。
<security-constraint>
<web-resource-collection>
<web-resource-name>HTTPSOnly</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>(5)重启Tomcat
4.附加信息
当我尝试crul时,我遇到了以下错误。
$ curl -v --tlsv1.1 https://[hostname]:8443/[appname]
* About to connect() to [hostname] port 8443 (#0)
* Trying [IP address]... connected
* Connected to [hostname] ([IP address]) port 8443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
* CAfile: /etc/pki/tls/certs/ca-bundle.crt
CApath: none
* NSS error -5990
* Closing connection #0
* SSL connect error
curl: (35) SSL connect errorCentOS : 6.10 Tomcat : 8.5
发布于 2020-12-31 15:07:39
确保您的server.xml文件具有正确的权限...最重要的是,您提到您使用的是JSP/servlet,所以有了web.xml
在web.xml中添加这些行
<security-constraint>
<web-resource-collection>
<web-resource-name>HTTPSOnly</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>https://stackoverflow.com/questions/65515892
复制相似问题