diff options
author | Filip Krzywka <filip.krzywka@nokia.com> | 2018-09-10 11:35:13 +0200 |
---|---|---|
committer | Filip Krzywka <filip.krzywka@nokia.com> | 2018-09-11 07:42:40 +0000 |
commit | 06c3751e4769f8c9fa13e4188fb41a2e9c796188 (patch) | |
tree | 93ec4b60359a7023cfc68bebe507f1fff267e4c4 /hv-collector-xnf-simulator | |
parent | 6b1777bf08c682fab15f158e9946e36f3cb9698a (diff) |
Enable ssl-disable option for xNF simulator
Change-Id: I8d4459c4b612e6066ae0da9521333fc3083952d3
Issue-ID: DCAEGEN2-760
Signed-off-by: Filip Krzywka <filip.krzywka@nokia.com>
Diffstat (limited to 'hv-collector-xnf-simulator')
-rw-r--r-- | hv-collector-xnf-simulator/src/main/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/adapters/VesHvClient.kt | 23 |
1 files changed, 15 insertions, 8 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 22e47d75..d1a5296a 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 @@ -19,6 +19,7 @@ */ package org.onap.dcae.collectors.veshv.simulators.xnf.impl.adapters +import arrow.core.Option import io.netty.handler.ssl.ClientAuth import io.netty.handler.ssl.SslContext import io.netty.handler.ssl.SslContextBuilder @@ -48,7 +49,7 @@ class VesHvClient(private val configuration: SimulatorConfiguration) { .options { opts -> opts.host(configuration.vesHost) .port(configuration.vesPort) - .sslContext(createSslContext(configuration.security)) + .sslContext(createSslContext(configuration.security).orNull()) } .build() @@ -92,13 +93,19 @@ class VesHvClient(private val configuration: SimulatorConfiguration) { .then() } - private fun createSslContext(config: SecurityConfiguration): SslContext = - SslContextBuilder.forClient() - .keyManager(config.cert.toFile(), config.privateKey.toFile()) - .trustManager(config.trustedCert.toFile()) - .sslProvider(SslProvider.OPENSSL) - .clientAuth(ClientAuth.REQUIRE) - .build() + private fun createSslContext(config: SecurityConfiguration): Option<SslContext> = + if (config.sslDisable) { + Option.empty() + } else { + Option.just( + SslContextBuilder.forClient() + .keyManager(config.cert.toFile(), config.privateKey.toFile()) + .trustManager(config.trustedCert.toFile()) + .sslProvider(SslProvider.OPENSSL) + .clientAuth(ClientAuth.REQUIRE) + .build() + ) + } private fun NettyOutbound.logConnectionClosed(): NettyOutbound { context().onClose { |