阿里云网站配置https证书 Tomcat服务器安装配置https证书
一、准备工作
1、有阿里云ECS和域名
2、申请SSL证书 --- 步骤略
3、下载SSL证书
二、证书格式转换
1、使用JDK提供的 keytool,将 .pfx证书转换为 .jks 证书
2、命令:
keytool -importkeystore -srckeystore 原来证书名称.pfx -destkeystore 转换后证书名称.jks -srcstoretype PKCS12 -deststoretype JKS
如:keytool -importkeystore -srckeystore www.xxx.com112233.pfx -destkeystore ssl_key0817.jks -srcstoretype PKCS12 -deststoretype JKS
3、win+R --- cmd --- 对应目录下 --- 执行上面命令 --- 转换后如下:
三、配置
1、使用Xftp将 ssl_key0817.jks 文件传到服务器 Tomcat/conf 文件夹下
2、修改Tomcat/conf/server.xml 配置文件,如下图所示:(文字版详细配置这里)
3、keystoreFile:证书文件位置 ; keystorePass:证书密码 (pfx-password.txt文件中)
4、web.xml 中增加如下配置,实现http跳转到https
<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、重启服务器,打开 阿里云ECS 443 端口
6、即可实现 https 配置啦!
四、总结
1、阿里云申请SSl证书
2、转换证书
3、配置证书 ---> 改3个端口
4、重启、开放端口即可
5、注意:阿里云SSL证书,只能在对应的ECS上配置调试,若在本地调试,是无效的,本地Tomcat配置SSL证书,点击这这里。