kpavlov / jreactive-8583

Kotlin/Java Client & Server for ISO8583 & Netty
Apache License 2.0
321 stars 147 forks source link

SSL/TLS #75

Open Carmy85 opened 5 years ago

Carmy85 commented 5 years ago

It's possible to enable communications using protocols such as SSL / TLS ?

Thanks

kpavlov commented 5 years ago

Hi, You should configure netty's SslContext using ConnectorConfigurer.

VovkaSOL commented 11 months ago

May be @kpavlov return to this good project

  client = Iso8583Client(socketAddress, configuration, isoMessageFactory).apply {
            configurer = object : ConnectorConfigurer<ClientConfiguration, Bootstrap> {
                override fun configurePipeline(pipeline: ChannelPipeline, configuration: ClientConfiguration) {
                    super.configurePipeline(pipeline, configuration)
                    if (sslConnectionProps.enableSsl) {
                        LOGGER.debug("Инициализация ssl клиента")
                        val ctx = getSslContext(sslConnectionProps.useClientCert, false)
                        //SslContextBuilder.forClient().trustManager()
                        val handler = ctx.newHandler(pipeline.channel().alloc()).apply {
                            engine().needClientAuth = true
                            engine().wantClientAuth = true
                            engine().useClientMode = true
                            this.handshakeFuture().addListener { f ->
                                if (!f.isSuccess) LOGGER.error("Клиентский SSL handshake failed" + f.cause().message)
                            }
                        }
                        pipeline.addAfter("Iso8583ChannelInitializer#0", "SSLHandler#0", handler)
                    }
                    if (showHexDumpLogs) {
                        pipeline.addAfter("iso8583Decoder", "hexLog", LoggingHandler(LogLevel.DEBUG))
                    }
                }
            }
        }
        client.addMessageListener(ClientResponseMessageListener(channelsCache, jsonIsoConverter))
        //client.configuration.replyOnError()=true
        client.init();
        client.connect()