From 4499975d9c240eab03e4a0a8ca66041a4005546f Mon Sep 17 00:00:00 2001 From: Dima Grossman Date: Sun, 29 Oct 2023 11:18:23 +0200 Subject: [PATCH] feat: add support for tls servername --- .idea/vcs.xml | 3 +-- .../providers/elasticache-cluster-provider.ts | 10 +++++++--- .../providers/memory-db-cluster-provider.ts | 10 +++++++--- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/.idea/vcs.xml b/.idea/vcs.xml index 314f5cd7912..a46828097c7 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -18,6 +18,5 @@ - - + \ No newline at end of file diff --git a/packages/application-generic/src/services/in-memory-provider/providers/elasticache-cluster-provider.ts b/packages/application-generic/src/services/in-memory-provider/providers/elasticache-cluster-provider.ts index 5b99a9055e6..d75e13e1196 100644 --- a/packages/application-generic/src/services/in-memory-provider/providers/elasticache-cluster-provider.ts +++ b/packages/application-generic/src/services/in-memory-provider/providers/elasticache-cluster-provider.ts @@ -48,7 +48,9 @@ export const getElasticacheClusterProviderConfig = keepAlive: process.env.REDIS_CLUSTER_KEEP_ALIVE, family: process.env.REDIS_CLUSTER_FAMILY, keyPrefix: process.env.REDIS_CLUSTER_KEY_PREFIX, - tls: process.env.REDIS_CLUSTER_TLS as ConnectionOptions, + tls: (process.env.ELASTICACHE_CLUSTER_SERVICE_TLS as ConnectionOptions) + ? { servername: process.env.ELASTICACHE_CLUSTER_SERVICE_HOST } + : {}, }; const host = redisClusterConfig.host; @@ -82,13 +84,14 @@ export const getElasticacheClusterProviderConfig = keepAlive, keyPrefix, ttl, + tls: redisClusterConfig.tls, }; }; export const getElasticacheCluster = ( enableAutoPipelining?: boolean ): Cluster | undefined => { - const { instances } = getElasticacheClusterProviderConfig(); + const { instances, password, tls } = getElasticacheClusterProviderConfig(); const options: ClusterOptions = { dnsLookup: (address, callback) => callback(null, address), @@ -96,7 +99,8 @@ export const getElasticacheCluster = ( enableOfflineQueue: false, enableReadyCheck: true, redisOptions: { - tls: {}, + tls, + ...(password && { password }), connectTimeout: 10000, }, scaleReads: 'slave', diff --git a/packages/application-generic/src/services/in-memory-provider/providers/memory-db-cluster-provider.ts b/packages/application-generic/src/services/in-memory-provider/providers/memory-db-cluster-provider.ts index a92a07168c3..7241e587dcd 100644 --- a/packages/application-generic/src/services/in-memory-provider/providers/memory-db-cluster-provider.ts +++ b/packages/application-generic/src/services/in-memory-provider/providers/memory-db-cluster-provider.ts @@ -51,7 +51,9 @@ export const getMemoryDbClusterProviderConfig = keepAlive: process.env.MEMORY_DB_CLUSTER_SERVICE_KEEP_ALIVE, family: process.env.MEMORY_DB_CLUSTER_SERVICE_FAMILY, keyPrefix: process.env.MEMORY_DB_CLUSTER_SERVICE_KEY_PREFIX, - tls: process.env.MEMORY_DB_CLUSTER_SERVICE_TLS as ConnectionOptions, + tls: (process.env.MEMORY_DB_CLUSTER_SERVICE_TLS as ConnectionOptions) + ? { servername: process.env.MEMORY_DB_CLUSTER_SERVICE_HOST } + : {}, }; const host = redisClusterConfig.host; @@ -87,20 +89,22 @@ export const getMemoryDbClusterProviderConfig = keepAlive, keyPrefix, ttl, + tls: redisClusterConfig.tls, }; }; export const getMemoryDbCluster = ( enableAutoPipelining?: boolean ): Cluster | undefined => { - const { instances, password, username } = getMemoryDbClusterProviderConfig(); + const { instances, password, username, tls } = + getMemoryDbClusterProviderConfig(); const options: ClusterOptions = { dnsLookup: (address, callback) => callback(null, address), enableAutoPipelining: enableAutoPipelining ?? false, enableOfflineQueue: false, redisOptions: { - tls: {}, + tls, connectTimeout: 10000, ...(password && { password }), ...(username && { username }),