在netty 中添加自帶的 SslHandler 就能支持HTTPS,但是添加之后使用 HTTP 訪問是存在問題的。請問如何能支持使用用一個端口兩種協(xié)議并行,比如在某個事件中判斷出使用 HTTPS 協(xié)議然后在把 SslHandler 添加到 pipeline 中。
SelfSignedCertificate ssc = new SelfSignedCertificate();
SslContext sslCtx = SslContextBuilder.forServer(ssc.certificate(), ssc.privateKey()).build();
SSLEngine sslEngine = sslCtx.newEngine(UnpooledByteBufAllocator.DEFAULT);
ch.pipeline().addFirst( new SslHandler(sslEngine));
添加回答
舉報
0/150
提交
取消