升级 https 记录
1、去阿里云购买证书(免费版),并提交审核资料
文章插图
购买的证书
2、下载证书
文章插图
下载证书
3、查看上图页面的第三步
文章插图
JKS证书安装
【SpringBoot中教你手把手配置 https】4、在证书目录下执行阿里云提供的命令,密码都填 pfx-password.txt 中的内容(三次),会生成 your-name.jks 文件 。
文章插图
生成 jks 证书
此处我已改名为 any.jks
5、将 any.jks 复制到 spring boot 应用的 resources 目录下
文章插图
移动证书
6、在 Application.yml 中配置证书及端口,密码填写第四步中的密码
文章插图
image.png
此配置会使 Undertow 容器监听 443 端口,那么只有在域名前添加 https:// 才能访问网站内容,添加 http:// 则不行,所以需要让 Undertow 容器监听 80 端口,并将 80 端口的所有请求重定向到 443 端口,即完成 http 到 https 的跳转 。
7、添加 SslConfig.JAVA,配置 Undertow 监听 80 端口 。
8、在 Spring Security 中配置 80 端口到 443 端口的映射 【待完善】
至此,重新打包应用,重新发布应用,即完成了 http 到 https 的升级,https 能让网站更安全,有兴趣的试试吧 。
推荐阅读
- JavaScript防抖与节流,你知道多少?
- 电脑提示“你的win10许可即将过期”
- 网络IP 、子网掩码 、路由器 、DNS知识你知道些什么
- APP是怎么给你推荐你喜欢的内容的?
- 很多人把像素和分辨率搞混了,一张图让你直观理解图像属性
- 解读黑客入侵你Linux服务器的一万种玩法
- 测试你成为富豪 测你以后会是个有钱人吗
- 七个指标教你鉴别优质普洱茶
- |职场黄金五年,决定你的一生(五)
- 洗面奶|刚打湿脸就涂洗面奶,难怪黑头越长越多,告诉你正确的洗脸方法