1、http想实现为https 就需要为配置ssl,及其使用的证书。这些在http里有专门的mod_ssl模块来支持。
执行: yum -y install mod_ssl #安装mod_ssl模块
安装该模块后,它会自动修改配置文件,增加LoadModule ssl_module modules/mod_ssl.so在httpd的子配置文件/etc/httpd/conf.d/ssl.conf里,同时也打开了443端口,同时指定了证书的存放路径。
2、如果申请证书时有填写私钥密码,下载可获得Tomcat文件夹,其中有密钥库 www.domain.com.jks;
如果没有填写私钥密码,证书下载包的Tomcat文件夹中包括密钥库文件www.domain.com.jks 与密钥库密码文件keystorePass.txt
3、复制证书文件到tomcat/conf下面
4、修改配置文件server.xml
5、修改在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>
6、开启443端口 重启服务即可。