사용자 관리

This commit is contained in:
현성필
2023-05-09 14:45:58 +09:00
parent f2f235d2ee
commit aea3c9dc7a
6 changed files with 53 additions and 5 deletions
@@ -13,9 +13,13 @@ import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.handler.codec.http.*;
import io.netty.handler.ssl.SslContext;
import io.netty.handler.ssl.SslContextBuilder;
import io.netty.handler.ssl.util.InsecureTrustManagerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.net.ssl.SSLException;
import java.util.concurrent.CompletableFuture;
@Service
@@ -40,6 +44,16 @@ public class NettyApiClient {
.handler(new ChannelInitializer<Channel>() {
@Override
public void initChannel(Channel ch) {
if (server.getScheme().equalsIgnoreCase("https")){
try {
final SslContext sslCtx = SslContextBuilder.forClient()
.trustManager(InsecureTrustManagerFactory.INSTANCE).build();
ch.pipeline().addLast(sslCtx.newHandler(ch.alloc(), host, port));// Add SSL handler
} catch (SSLException e) {
throw new RuntimeException(e);
}
}
ch.pipeline().addLast(new HttpClientCodec());
ch.pipeline().addLast(new HttpObjectAggregator(65536));
ch.pipeline().addLast(new HttpContentDecompressor());