diff options
author | 2018-11-20 13:58:12 +0100 | |
---|---|---|
committer | 2018-11-21 13:30:46 +0000 | |
commit | 875e379f528df93e5b9794a32fff02ab7e1236a5 (patch) | |
tree | addd3736320ce615576e7b8e69742284608600a3 /hv-collector-xnf-simulator/src | |
parent | 7d802e8716b08f84839307bf6a184d4c145800ca (diff) |
Fix xNF simulator sslContext
If --ssl-disable flag is specified in command line arguments, we shouldn't
put sslContext into TcpClient as this results in IllegalArgument.
Change-Id: I2e2d2ea89736f1e372e1b408c8f3cbe50bf1ecea
Issue-ID: DCAEGEN2-985
Signed-off-by: Filip Krzywka <filip.krzywka@nokia.com>
Diffstat (limited to 'hv-collector-xnf-simulator/src')
-rw-r--r-- | hv-collector-xnf-simulator/src/main/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/adapters/VesHvClient.kt | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/hv-collector-xnf-simulator/src/main/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/adapters/VesHvClient.kt b/hv-collector-xnf-simulator/src/main/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/adapters/VesHvClient.kt index 8df416c9..57aaf3db 100644 --- a/hv-collector-xnf-simulator/src/main/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/adapters/VesHvClient.kt +++ b/hv-collector-xnf-simulator/src/main/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/adapters/VesHvClient.kt @@ -20,10 +20,8 @@ package org.onap.dcae.collectors.veshv.simulators.xnf.impl.adapters import arrow.core.Option -import io.netty.handler.ssl.ClientAuth +import arrow.core.getOrElse import io.netty.handler.ssl.SslContext -import io.netty.handler.ssl.SslContextBuilder -import io.netty.handler.ssl.SslProvider import org.onap.dcae.collectors.veshv.domain.WireFrameMessage import org.onap.dcae.collectors.veshv.domain.SecurityConfiguration import org.onap.dcae.collectors.veshv.domain.WireFrameEncoder @@ -47,9 +45,12 @@ class VesHvClient(private val configuration: SimulatorConfiguration) { private val client: TcpClient = TcpClient.create() .host(configuration.vesHost) .port(configuration.vesPort) - .secure { sslSpec -> - createSslContext(configuration.security).fold({}, sslSpec::sslContext) - } + .configureSsl() + + private fun TcpClient.configureSsl() = + createSslContext(configuration.security) + .map { sslContext -> this.secure(sslContext) } + .getOrElse { this } fun sendIo(messages: Flux<WireFrameMessage>) = sendRx(messages).then(Mono.just(Unit)).asIo() |