Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use SSL Context to connect to Redis instance on AWS Elasticache with Encryption In-Transit enabled #267

Closed
saragallagherpdgc opened this issue Apr 7, 2021 · 1 comment

Comments

@saragallagherpdgc
Copy link

saragallagherpdgc commented Apr 7, 2021

I am unable to properly connect to a Redis Instance on Elasticache with Encryption In-Transit enabled. I can connect to the redis client on the read. However on the write nothing happens, my job just hangs and eventually times out. The elasticache does not have any authentication. @mattusifer I saw that you wrote the code for SSL Context, if you could provide any insight that'd be great. Thanks!

object RedisClient {
var writeHost: String = "HOST"
var readHost: String = "HOST"
var port: Int = 6379
var keyTTL: Int = 3600
var maxIdle: Int = 8
var database: Int = 0
var secret: Option[Any] = None
var timeout: Int = 300000
var maxConnections: Int = RedisClientPool.UNLIMITED_CONNECTIONS
var poolWaitTimeout: Int = 3000

private val sslContext = SSLContext.getInstance("TLS")

private lazy val writePool = new RedisClientPool(writeHost, port, maxIdle, database, secret, timeout, maxConnections, poolWaitTimeout, Some(sslContext))
private lazy val readPool = new RedisClientPool(readHost, port, maxIdle, database, secret, timeout, maxConnections, poolWaitTimeout)

def getCount(id: String): Option[String] = {
readPool.withClient(client => {
client.get(id)
})
}

def setCount(id: String, count: String): Boolean = writePool.withClient(client => {
client.setex(id, keyTTL, count)
})

def close(): Unit = {
readPool.close()
writePool.close()
}
}

@zizzle6717
Copy link
Collaborator

Try something like this new RedisClient("your-aws-endpoint", 6379, sslContext = Some(SSLContext.getDefault()), secret = "your-auth-secret")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants