not an SSL/TLS record 解码输出
2018-08-13 本文已影响0人
jeho0815
在Netty中,如果开启了https,但是你使用http请求来发送请求,那么会打印一个SSL/TLS异常,如下:
2018-08-13 02:24:36.782 WARN [vert.x-eventloop-thread-2] i.n.c.DefaultChannelPipeline[151]: An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception.
io.netty.handler.codec.DecoderException: io.netty.handler.ssl.NotSslRecordException: not an SSL/TLS record: 474554202f637365656e67696e652f76312f656e67696e65733f706167652d6e6f3d3126706167652d73697a653d333020485454502f312e310d0a486f73743a203139322e3134352e3130342e39363a33303131370d0a436f6e6e656374696f6e3a206b6565702d616c6976650d0a557365722d4167656e743a204d6f7a696c6c612f352e30202857696e646f7773204e5420362e313b20574f57363429204170706c655765624b69742f3533372e333620284b48544d4c2c206c696b65204765636b6f29204368726f6d652f36382e302e333434302e3735205361666172692f3533372e33360d0a43616368652d436f6e74726f6c3a206e6f2d63616368650d0a782d617574682d746f6b656e3a204d4949533267594a4b6f5a496876634e415163436f494953797a434345736343415145784454414c42676c67686b67425a514d45416745776768456f42676b71686b694739773042427747676768455a4249495246587369644739725a5734694f6e73695a58687761584a6c6331396864434936496a49774d5467744d4467744d5452554d4445364e4467364d4441754d7a597a4d44417757694973496d316c644768765a484d694f6c73696347467a63336476636d51695853776959324630595778765a79493657313073496e4a766247567a496a706265794a755957316c496a6f696447566659575274615734694c434a705a434936496a45354f544a6a4d57526d4f57466b4e6a51784d6d5535597a677a4d7a417a4d6d4e6b4e7a426a5954686d496e307365794a755957316c496a6f69623342665a3246305a5752665a576c7758326c77646a59694c434a705a434936496a416966537837496d3568625755694f694a766346396e5958526c5a46396861584e665a47566d623263694c434a705a434936496a416966537837496d3568625755694f694a766346396e5958526c5a46396b6146397459794973496d6c6b496a6f694d434a394c487369626d46745a534936496d3977583264686447566b583246706331397a6458426c636c39795a584e76624856306157397549697769615751694f694977496e307365794a755957316c496a6f69623342665a3246305a575266593239735a434973496d6c6b496a6f694d434a394c487369626d46745a534936496d3977583264686447566b58334a6b633139746557397764434973496d6c6b496a6f694d434a394c487369626d46745a534936496d3977583264686447566b583246706331397659334a66596d46756131396a59584a6b49697769615751694f694977496e307365794a755957316c496a6f69623342665a3246305a57526659324a7a58334668596d393049697769615751694f694977496e307365794a755957316c496a6f69623342665a3246305a575266626d5633
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:459)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:265)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1434)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:965)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:645)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:580)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:497)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:459)
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:884)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:748)
Caused by: io.netty.handler.ssl.NotSslRecordException: not an SSL/TLS record: 474554202f637365656e67696e652f76312f656e67696e65733f706167652d6e6f3d3126706167652d73697a653d333020485454502f312e310d0a486f73743a203139322e3134352e3130342e39363a33303131370d0a436f6e6e656374696f6e3a206b6565702d616c6976650d0a557365722d4167656e743a204d6f7a696c6c612f352e30202857696e646f7773204e5420362e313b20574f57363429204170706c655765624b69742f3533372e333620284b48544d4c2c206c696b65204765636b6f29204368726f6d652f36382e302e333434302e3735205361666172692f3533372e33360d0a43616368652d436f6e74726f6c3a206e6f2d63616368650d0a782d617574682d746f6b656e3a204d4949533267594a4b6f5a496876634e415163436f494953797a434345736343415145784454414c42676c67686b67425a514d45416745776768456f42676b71686b694739773042427747676768455a4249495246587369644739725a5734694f6e73695a58687761584a6c6331396864434936496a49774d5467744d4467744d5452554d4445364e4467364d4441754d7a597a4d44417757694973496d316c644768765a484d694f6c73696347467a63336476636d51695853776959324630595778765a79493657313073496e4a766247567a496a706265794a755957316c496a6f696447566659575274615734694c434a705a434936496a45354f544a6a4d57526d4f57466b4e6a51784d6d5535597a677a4d7a417a4d6d4e6b4e7a426a5954686d496e307365794a755957316c496a6f69623342665a3246305a5752665a576c7758326c77646a59694c434a705a434936496a416966537837496d3568625755694f694a766346396e5958526c5a46396861584e665a47566d623263694c434a705a434936496a416966537837496d3568625755694f694a766346396e5958526c5a46396b6146397459794973496d6c6b496a6f694d434a394c487369626d46745a534936496d3977583264686447566b583246706331397a6458426c636c39795a584e76624856306157397549697769615751694f694977496e307365794a755957316c496a6f69623342665a3246305a575266593239735a434973496d6c6b496a6f694d434a394c487369626d46745a534936496d3977583264686447566b58334a6b633139746557397764434973496d6c6b496a6f694d434a394c487369626d46745a534936496d3977583264686447566b583246706331397659334a66596d46756131396a59584a6b49697769615751694f694977496e307365794a755957316c496a6f69623342665a3246305a57526659324a7a58334668596d393049697769615751694f694977496e307365794a755957316c496a6f69623342665a3246305a575266626d5633
at io.netty.handler.ssl.SslHandler.decodeJdkCompatible(SslHandler.java:1156)
at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1221)
at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:489)
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:428)
... 16 common frames omitted
我们可以把这个16进制编码流解码出来看下内容是什么:
String code = "474554202f637365656e67696e652f76312f656e67696e65733f706167652d6e6f3d3126706167652d73697a653d333020485454502f312e310d0a486f73743a203139322e3134352e3130342e39363a33303131370d0a436f6e6e656374696f6e3a206b6565702d616c6976650d0a43616368652d436f6e74726f6c3a206d61782d6167653d300d0a557067726164652d496e7365637572652d52657175657374733a20310d0a557365722d4167656e743a204d6f7a696c6c612f352e30202857696e646f7773204e5420362e313b20574f57363429204170706c655765624b69742f3533372e333620284b48544d4c2c206c696b65204765636b6f29204368726f6d652f36382e302e333434302e3735205361666172692f3533372e33360d0a4163636570743a20746578742f68746d6c2c6170706c69636174696f6e2f7868746d6c2b786d6c2c6170706c69636174696f6e2f786d6c3b713d302e392c696d6167652f776562702c696d6167652f61706e672c2a2f2a3b713d302e380d0a4163636570742d456e636f64696e673a20677a69702c206465666c6174650d0a4163636570742d4c616e67756167653a207a682d434e2c7a683b713d302e392c656e3b713d302e380d0a0d0a";
byte[] bytes = ByteBufUtil.decodeHexDump(code);
System.out.println(new String(bytes));
解出来内容如下:
GET /cseengine/v1/engines?page-no=1&page-size=30 HTTP/1.1
Host: 192.145.104.96:30117
Connection: keep-alive
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.75 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8