Spring Boot开发HTTPS协议的REST接口
2017-06-12 15:04
337 查看
Spring Boot开发HTTP的REST接口流程在前文中已经描述过,见《SpringBoot开发REST接口》。
如需要支持HTTPS,只需要在如上基础上进行设置。修改/resources/application.properties文件,添加ssl配置。
如需要支持HTTPS,只需要在如上基础上进行设置。修改/resources/application.properties文件,添加ssl配置。
server.port=8443 server.ssl.key-store=classpath:keystore.p12 server.ssl.key-store-password=yourpassword
server.ssl.keyStoreType=PKCS12 server.ssl.keyAlias=tomcat
并将对应的KeyStore文件放在classpath下,如图:
*关于keystore.p12的生成,使用jdk自带的keytools执行命令,会在当前目录下生成对应keystore文件:
keytool -genkey -alias tomcat -storetype PKCS12 -keyalg RSA -keysize 2048 -keystore keystore.p12 -validity 3650
ps:如果是在生产环境中开发HTTPS接口,不一定需要spring boot直接提供https协议,而是可以通过nginx转发,这样的好处是,nginx服务器统一管理证书,也简化了后端服务的开发。
相关文章推荐
- 使用Spring Boot开发Web项目(二)之添加HTTPS支持
- 使用Spring Boot开发Web项目(二)之添加HTTPS支持
- 使用Spring Boot开发Web项目(二)之添加HTTPS支持
- Spring Boot支持tomcat服务器,支持http、https(ssl、tls)双协议,支持双端口
- 玩转SpringBoot - 03 开启https协议访问
- 使用Spring Boot开发Web项目(二)之添加HTTPS支持
- Spring Boot支持Jetty服务器,支持http、https(ssl、tls)双协议,支持双端口
- SpringBoot2.0如何启用https协议
- 使用Spring Boot开发Web项目(二)之添加HTTPS支持
- 使用Spring Boot开发Web项目(二)之添加HTTPS支持
- 使用Spring Boot开发Web项目(二)之添加HTTPS支持
- 使用Spring Boot开发Web项目(二)之添加HTTPS支持
- Spring Boot开发之流水无情(二)
- 在Spring Boot中使用Https
- Spring Boot实践应用开发(8)
- Spring Boot——开发新一代Spring应用
- Enable HTTPS in Spring Boot
- springboot 开发入门,及问题汇总
- Spring Boot——开发新一代Spring应用