aboutsummaryrefslogtreecommitdiffstats
path: root/sources/hv-collector-ssl
diff options
context:
space:
mode:
authorJakub Dudycz <jakub.dudycz@nokia.com>2019-03-01 17:39:09 +0100
committerFilip Krzywka <filip.krzywka@nokia.com>2019-03-05 09:08:12 +0100
commit756e7210cf13c6ef9bae8f785d3f46112c136f7d (patch)
treecacd684842f901379664fe22eea957386e4dbe96 /sources/hv-collector-ssl
parentc50b6606f4af4452d1b107929956775e86e366c1 (diff)
Fix ssl related bug in xnf simulator
Fix bug when xnf simnulator was using same SecurityKeys object instance for every new VesClient, which resulted in fault while trying to connect to collector. With new implementation simulator reuses same HvVesProdcuer from SDK for every VesEvent request received and creates new Producer for every WireFrameEvent request. This allows to continue testing cases in which there is need to assert if connection was dropped from malicious client. Change-Id: I5f51a58de85cccf7de6ab2392f86259502be31dd Issue-ID: DCAEGEN2-1291 Signed-off-by: Jakub Dudycz <jakub.dudycz@nokia.com> Signed-off-by: Filip Krzywka <filip.krzywka@nokia.com>
Diffstat (limited to 'sources/hv-collector-ssl')
-rw-r--r--sources/hv-collector-ssl/src/main/kotlin/org/onap/dcae/collectors/veshv/ssl/boundary/utils.kt16
1 files changed, 11 insertions, 5 deletions
diff --git a/sources/hv-collector-ssl/src/main/kotlin/org/onap/dcae/collectors/veshv/ssl/boundary/utils.kt b/sources/hv-collector-ssl/src/main/kotlin/org/onap/dcae/collectors/veshv/ssl/boundary/utils.kt
index fb142639..478713e2 100644
--- a/sources/hv-collector-ssl/src/main/kotlin/org/onap/dcae/collectors/veshv/ssl/boundary/utils.kt
+++ b/sources/hv-collector-ssl/src/main/kotlin/org/onap/dcae/collectors/veshv/ssl/boundary/utils.kt
@@ -42,14 +42,19 @@ const val KEY_STORE_FILE = "/etc/ves-hv/server.p12"
const val TRUST_STORE_FILE = "/etc/ves-hv/trust.p12"
fun createSecurityConfiguration(cmdLine: CommandLine): Try<SecurityConfiguration> =
- if (cmdLine.hasOption(CommandLineOption.SSL_DISABLE))
- Try { disabledSecurityConfiguration() }
+ createSecurityConfigurationProvider(cmdLine).map { it() }
+
+fun createSecurityConfigurationProvider(cmdLine: CommandLine): Try<() -> SecurityConfiguration> =
+ if (shouldDisableSsl(cmdLine))
+ Try { { disabledSecurityConfiguration() } }
else
- enabledSecurityConfiguration(cmdLine)
+ Try { { enabledSecurityConfiguration(cmdLine) } }
+
+private fun shouldDisableSsl(cmdLine: CommandLine) = cmdLine.hasOption(CommandLineOption.SSL_DISABLE)
private fun disabledSecurityConfiguration() = SecurityConfiguration(keys = None)
-private fun enabledSecurityConfiguration(cmdLine: CommandLine) = Try {
+private fun enabledSecurityConfiguration(cmdLine: CommandLine): SecurityConfiguration {
val ksFile = cmdLine.stringValue(CommandLineOption.KEY_STORE_FILE, KEY_STORE_FILE)
val ksPass = cmdLine.stringValue(CommandLineOption.KEY_STORE_PASSWORD).getOrElse { "" }
val tsFile = cmdLine.stringValue(CommandLineOption.TRUST_STORE_FILE, TRUST_STORE_FILE)
@@ -62,7 +67,8 @@ private fun enabledSecurityConfiguration(cmdLine: CommandLine) = Try {
.trustStorePassword(Passwords.fromString(tsPass))
.build()
- SecurityConfiguration(keys = Some(keys))
+ return SecurityConfiguration(keys = Some(keys))
}
+
private fun pathFromFile(file: String) = Paths.get(file)