<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="443" />
<Connector port="443" protocol="org.apache.coyote.http11.Http11Protocol"
maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
clientAuth="false"
sslProtocol="TLS"
keystoreFile="/home/doc/keys/213972284410468.pfx"
keystoreType="PKCS12"
keystorePass="213972284410468" />
添加keystoreFile,keystoreType,keystorePass即可进行https访问。
6、自动跳转到https连接
如果希望输入http链接时自动跳转到https,需要在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>
以上内容位置在</web-app>内,添加后输入http访问时会自动跳转到https连接。
7、https访问端口号缺省
Tomcat中https默认端口为8443,该为443后可进行端口号缺省访问系统。如下:
<Connector port="443" protocol="org.apache.coyote.http11.Http11Protocol"
maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
clientAuth="false"
sslProtocol="TLS"
keystoreFile="/home/doc/keys/213972284410468.pfx"
keystoreType="PKCS12"
keystorePass="213972284410468" />