文章
2017/9/21
Tomcat设置SSL
2017-09-21
无标签

在终端执行命令生成```
.keystore

keytool -genkey -alias tomcat -keyalg RSA

输入所需信息,如果买了的跳过生成这个步骤
之后生成了一个```
~/.keystore

编辑 server.xml,添加

Connector SSLEnabled="true" acceptCount="100" clientAuth="false"
disableUploadTimeout="true" enableLookups="false" maxThreads="25"
port="端口号" keystoreFile="你的.keystore绝对路径" keystorePass="设置的密码"
protocol="org.apache.coyote.http11.Http11NioProtocol" scheme="https"
secure="true" sslProtocol="TLS" />

如果需要强制启用(只能使用 HTTPS ,使用 HTTP 访问会自动跳转),编辑 web.xml ,在``` <web-app>

内添加

<security-constraint>
<web-resource-collection>
<web-resource-name>securedapp</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>