【SpringBoot配置Https】

Spring Boot 配置SSL很简单,只需要通过一系列的 server.ssl.* 参数即可完成配置,如下所示。
application.properties配置文件参考配置:

server.port = 8443
server.ssl.protocol=TLS
server.ssl.key-store=classpath: javastack.keystore
server.ssl.key-store-password=javastack
server.ssl.key-store-type=JKS

这边只是提供了一个SSL单向演示的验证。更多的SSL参数配置如下:

server.ssl.ciphers= # Supported SsL ciphers.
server.ssl.client-auth= # whether client authentication is wanted ( "want" ) orneeded ( "need " ) . Requires a trust store.
server.ssl.enabled-protocols= # Enabled SSL protocols.
server.ssl.key-alias= # Alias that identifies the key in the key store.
server.ssl.key-password= # Password used to access the key in the key store.
server.ssl.key-store= # Path to the key store that holds the SsL certificate(ypically a jks file ) .
server.ssl.key-store-password= # Password used to access the key store.
server.ssl.key-store-provider= # Provider for the key store.
server.ssl.protocol=TLS # SSL protocol to use.
server.ssl.trust-store= # Trust store that holds sSL certificates.
server.ssl.trust-store-password= # Password used to access the trust store.
server.ssl.trust-store-provider= # Provider for the trust store.
server.ssl.trust-store-type= # Type of the trust store.

参数对应的类: org.springframework.boot.web.server.Ssl

上面的例子配置后就能开启HTTPS了,默认的HTTP协议就不再支持了,Spring Boot不支持以配置文件配置的方式同时支持HTTP和HTTPS。如何同时配置可以看我的另一篇文章《SpringBoot如何同时支持Http和Https》

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

业余码手

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值