| | |
| | | public class ChildChannelHandler extends ChannelInitializer<SocketChannel> { |
| | | @Override |
| | | protected void initChannel(SocketChannel socketChannel) throws Exception { |
| | | // String path = "C:\\app\\cert\\tomcat\\www.gzjwzc.com.pfx"; |
| | | // SSLContext sslContext = createSSLContext.createSSLContext("PKCS12" |
| | | // , path, "79uc9bsd"); |
| | | // String path = "/root/server/app/cert/qytzt.cn.jks"; |
| | | // SSLContext sslContext = createSSLContext.createSSLContext("JKS" |
| | | // , path, "bo27xqbr"); |
| | | // SSLEngine engine = sslContext.createSSLEngine(); |
| | | |
| | | |
| | | File path = new File("/root/server/app/cert/qytzt.cn.key"); |
| | | File path1 = new File("/root/server/app/cert/qytzt.cn.pem"); |
| | | SslContext sslContext = SslContextBuilder.forServer(path, path1, null).clientAuth(ClientAuth.NONE).build(); |
| | | |
| | | //SSLEngine 此类允许使用ssl安全套接层协议进行安全通信 |
| | | SSLEngine engine = sslContext.newEngine(socketChannel.alloc()); |
| | | engine.setUseClientMode(false); |
| | | socketChannel.pipeline().addLast("ssl", new SslHandler(engine)); |
| | | // //SSLEngine 此类允许使用ssl安全套接层协议进行安全通信 |
| | | // engine.setUseClientMode(false); |
| | | // socketChannel.pipeline().addLast("ssl", new SslHandler(engine)); |
| | | |
| | | // 设置30秒没有读到数据,则触发一个READER_IDLE事件。 |
| | | // pipeline.addLast(new IdleStateHandler(30, 0, 0)); |