赞
踩
当时的环境:阿里云的域名,腾讯云的服务器。在阿里云上面申请的免费ssl证书。根据你的服务器下载相应的ssl证书,我下的是tomcat和nginx两个版本的。
首先在tomcat中部署ssl:
1. 解压在阿里云申请的ssl证书,共有两个文件,一个pfx版的证书,一个密码txt。在tomcat安装目录下的conf文件夹中新建cert文件夹,将证书和密码文件通过xftp传送到该文件夹下。
2.通过命令将PFX格式证书转换为JKS格式证书
keytool -importkeystore -srckeystore 你的证书名称.pfx -destkeystore 新证书的名字.jks -srcstoretype PKCS12 -deststoretype JKS
3.回车,会提示你输入密码,建议三次都输入密码txt中的密码。
4.修改server.xml文件
添加<Connector port="443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
keystoreFile="证书的路径"
keystorePass=" 密码txt中的密码"
clientAuth="false" sslProtocol="TLS" />
将8443修改为443
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>
至此完成了tomcat配置ssl,将http转化为https。
效果图:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。