申请免费SSL证书和配置Tomcat自动跳转Https

文章目录
  1. 配置tomcat的自动跳转https

如何申请免费的SSL证书,以及配置Tomcat自动跳转https

参考文档

配置tomcat的自动跳转https

server.xml中配置

1
2
3
4
5
6
7
8
9
10
11
12
13
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="443" />

<Connector port="443" protocol="org.apache.coyote.http11.Http11AprProtocol"
maxThreads="150" SSLEnabled="true" >
<UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol" />
<SSLHostConfig>
<Certificate certificateKeyFile="conf/server.key"
certificateKeyPassword="password"
certificateFile="conf/server.crt"/>
</SSLHostConfig>
</Connector>

web.xml中配置

1
2
3
4
5
6
7
8
9
<security-constraint>
<web-resource-collection>
<web-resource-name>SSL</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>