java - Spring Boot 启用 HTTPS
问题描述
我正在使用 Spring Boot 2.3 来创建微服务。我需要启用 HTTPS 并禁用 HTTP 调用。我有 .pfx 格式的证书。我从https://www.thomasvitale.com/https-spring-boot-ssl-certificate/尝试了以下步骤
server.port=8443
server.ssl.key-store-type=PKCS12
server.ssl.key-store=classpath:mycert.pfx
server.ssl.key-store-password=password
security.require-ssl=true
由于我们使用的是 Spring Boot 安全性,因此也添加了以下行,
http
.requiresChannel()
.anyRequest()
.requiresSecure();
在 WebSecurityConfigurerAdapter 的配置方法中。但是通过这些配置,我可以获得 HTTP 和 HTTPS 的响应。所以我不确定 HTTPS 是否真的像我配置的 requiressecure 那样工作,但它不工作。在密钥库属性中提及 pfx 文件是否正确?
解决方案
推荐阅读
- java - Checkstyle SuppressionCommentFilter
- xslt - XSLT 2.0 如何在输出的 tokenize() 中测试 position()
- three.js - 在 three.js 中显示为平面的 3D 对象
- java - java中错误的文件路径
- android - 更好地理解 onTouchListener
- javascript - 获取实例的孙子
- c# - c# 按对象列表排序
- c# - 无法将图像文件上传到 Firebase 存储 - Unity C#
- java - How to test json response returned by rest controller endpoint
- c# - 使用翻译功能跳转的问题 [Unity 2D]