Skip to content

Commit

Permalink
Merge pull request #595 from Landoop/fix/redis_enable_tls
Browse files Browse the repository at this point in the history
Only set jks if config is set
  • Loading branch information
spirosoik authored Jul 11, 2019
2 parents 99182dc + 105ade9 commit 2c656b9
Showing 1 changed file with 19 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,32 +37,35 @@ abstract class RedisWriter extends DbWriter with StrictLogging with ConverterUti
val connection = sinkSettings.connectionInfo

if (connection.isSslConnection) {
val keyStoreFilepath = connection.keyStoreFilepath match {
case Some(path) =>
if (!new File(path).exists) {
throw new FileNotFoundException(s"Keystore Certificate not found in: $path")
}

val keyStoreFilepath = connection.keyStoreFilepath.getOrElse("")
System.setProperty("javax.net.ssl.keyStorePassword", connection.keyStorePassword.getOrElse(""))
System.setProperty("javax.net.ssl.keyStore", path)
System.setProperty("javax.net.ssl.keyStoreType", connection.keyStoreType.getOrElse("jceks"))

if (!new File(keyStoreFilepath).exists) {
throw new FileNotFoundException(s"Keystore Certificate not found in: $keyStoreFilepath")
case None =>
}

val trustStoreFilepath = connection.trustStoreFilepath.getOrElse("")
connection.trustStoreFilepath match {
case Some(path) =>
if (!new File(path).exists) {
throw new FileNotFoundException(s"Truststore Certificate not found in: $path")
}

if (!new File(trustStoreFilepath).exists) {
throw new FileNotFoundException(s"Truststore Certificate not found in: $trustStoreFilepath")
}

System.setProperty("javax.net.ssl.keyStorePassword", connection.keyStorePassword.getOrElse(""))
System.setProperty("javax.net.ssl.keyStore", keyStoreFilepath)
System.setProperty("javax.net.ssl.keyStoreType", connection.keyStoreType.getOrElse("jceks"))
System.setProperty("javax.net.ssl.trustStorePassword", connection.trustStorePassword.getOrElse(""))
System.setProperty("javax.net.ssl.trustStore", path)
System.setProperty("javax.net.ssl.trustStoreType", connection.trustStoreType.getOrElse("jceks"))

System.setProperty("javax.net.ssl.trustStorePassword", connection.trustStorePassword.getOrElse(""))
System.setProperty("javax.net.ssl.trustStore", trustStoreFilepath)
System.setProperty("javax.net.ssl.trustStoreType", connection.trustStoreType.getOrElse("jceks"))
case None =>
}
}

jedis = new Jedis(connection.host, connection.port, connection.isSslConnection)

connection.password.foreach(p => jedis.auth(p))

//initialize error tracker
initialize(sinkSettings.taskRetries, sinkSettings.errorPolicy)
}
Expand Down

0 comments on commit 2c656b9

Please sign in to comment.