配置https访问, 添加以下代码l
<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
maxThreads="150" SSLEnabled="true"
scheme="https" secure="true"
keystoreFile="XXXX.pfx"
keystorePass="证书密钥"
keyAlias="alias"
clientAuth="false"
SSLProtocol="TLSv1+TLSv1.1+TLSv1.2">
<!-- <SSLHostConfig>
<Certificate certificateKeystoreFile="/opt/tomcat/conf/cert/2025125_www.harrisonlee1998.com.pfx"
type="PFX"/>
</SSLHostConfig> -->
</Connector>
强制https访问
在tomcat的web.xml中末尾加上如下代码:
<login-config>
<!-- Authorization setting for SSL -->
<auth-method>CLIENT-CERT</auth-method>
<realm-name>Client Cert Users-only Area</realm-name>
</login-config>
<security-constraint>
<!-- Authorization setting for SSL -->
<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>