tomcat配置https

http访问tomcat默认端口是80,http://域名
https访问tomcat 的端口是443,https://域名
https访问tomcat的8443端口就相当于http访问tomcat的8080端口,需要在域名后面拼接端口号,http://域名:8080,https://域名:8443。

server.xml配置如下。

1、<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="443" />
2、<Connector port="443" protocol="HTTP/1.1" SSLEnabled="true" maxThreads="150" scheme="https" secure="true" clientAuth="false" sslProtocol="TLS" keystoreFile="C:/soft/tomcat.keystore" keystorePass="123456"/>
3、<Connector port="8009" enableLookups="false" protocol="AJP/1.3" redirectPort="443" />
上面的443是由原本的8443修改的,因为443(https)相当于80(http)的端口。其中2在http访问的下是被注释掉的,而在https才可以使用。

web.xml的配置如下

在web.xml文件的倒数第二行(</welcome-file-list>下面)添加如下配置。

<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>

参考地址:https://www.cnblogs.com/luchangyou/p/6028067.html

posted @ 2019-01-18 17:05  明天,你好啊  阅读(1448)  评论(0编辑  收藏  举报