1.申请ssl证书
2.下载ssl证书 打开此网址 https://myssl.com/cert_convert.html 将证书文件(xxx.com.crt)和密钥文件上传(xxx.com.key) 输入密码后会得到一个jks的文件。上传到你的tomcat的conf文件夹下即可。
3.修改server.xml
这是tomcat原样字段
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
修改为下面这样的
<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="443" />
<Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol"
maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" />
-->
//上面这部分是server.xml中原样的字段
<Connector port="443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
keystoreFile="conf/xxxxxx.com.jks" //这里是你的jks的路径如果你是放在conf下 修改文件名即可。
keystorePass="123456" //这是你在前面网站上设定的密码
clientAuth="false" sslProtocol="TLS" />
4.修改web.xml
在web.xml最后粘贴这段代码。位置在<welcome-file-list>节点下面
<!-- SSL证书配置添加如下 -->
<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>
5.重启tomcat,是重启!!!!!!!!!!!!!
6.如果还是不可以,检查自己是否安装了ssl相关的模块。