如何在春季云网关中使用 SSL



配置文件如下:

server:
port: 8080
ssl:
enabled: true
key-store: D:/https/portal.keystore
key-store-password: 222222
http2:
enabled: true

由 Java KeyTool 生成的密钥库。 项目可以正常启动,当我通过网关请求时,是错误的。 消息如下:

io.netty.handler.ssl.NotSslRecordException: 不是 SSL/TLS 记录: 474554202f55414d532f75616d737465737420485454502f312e310d0a486f73743a203139322e3136382e302e3131313a383038300d0a436f6e6e656374696f6e3a206b6565702d616c6976650d0a43616368652d436f6e74726f6c3a206d61782d6167653d300d0a557067726164652d496e7365637572652d52657175657374733a20310d0a557365722d4167656e743a204d6f7a696c6c612f352e30202857696e646f7773204e542031302e303b20574f57363429204170706c655765624b69742f3533372e333620284b48544d4c2c206c696b65204765636b6f29204368726f6d652f36392e302e333439372e313030205361666172692f3533372e33360d0a4163636570743a20746578742f68746d6c2c6170706c69636174696f6e2f7868746d6c2b786d6c2c6170706c69636174696f6e2f786d6c3b713d302e392c696d6167652f776562702c696d6167652f61706e672c2a2f2a3b713d302e380d0a4163636570742d456e636f64696e673a20677a69702c206465666c6174650d0a4163636570742d4c616e67756167653a207a682d434e2c7a683b713d302e392c656e3b713d302e380d0a436f6f6b69653a2053455353494f4e3d61663534343537362d376363342d343832332d383163362d6662343936663165326232370d0a0d0a在 io.netty.handler.ssl.SslHandler.decodeJdkCompatible(SslHandler.java:1156( [netty-handler-4.1.27.Final.jar:4.1.27.Final] at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1221( [netty-handler-4.1.27.Final.jar:4.1.27.Final] at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:489( [netty-codec-4.1.27.Final.jar:4.1.27.Final] at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:428( [netty-codec-4.1.27.Final.jar:4.1.27.Final] at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:265( [netty-codec-4.1.27.Final.jar:4.1.27.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362( [netty-transport-4.1.27.Final.jar:4.1.27.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348( [netty-transport-4.1.27.Final.jar:4.1.27.Final] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340( [netty-transport-4.1.27.Final.jar:4.1.27.Final] at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1434( [netty-transport-4.1.27.Final.jar:4.1.27.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362( [netty-transport-4.1.27.Final.jar:4.1.27.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348( [netty-transport-4.1.27.Final.jar:4.1.27.Final] at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:965( [netty-transport-4.1.27.Final.jar:4.1.27.Final] at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163( [netty-transport-4.1.27.Final.jar:4.1.27.Final] at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:646( [netty-transport-4.1.27.Final.jar:4.1.27.Final] at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:581( [netty-transport-4.1.27.Final.jar:4.1.27.Final] at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:498( [netty-transport-4.1.27.Final.jar:4.1.27.Final] at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:460( [netty-transport-4.1.27.Final.jar:4.1.27.Final] at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:884( [netty-common-4.1.27.Final.jar:4.1.27.Final] at java.lang.Thread.run(Thread.java:748( [na:1.8.0_171]

我知道为什么我错了,我配置了 spring 云网关 https,但我请求没有 keysturst.store 的网关服务,它工作错误。

所以我要求使用keystrust.store请求服务,问题已经解决。

相关内容

  • 没有找到相关文章

最新更新