Skip to content

Commit

Permalink
clusters: copy TLS configuration to shards
Browse files Browse the repository at this point in the history
  • Loading branch information
attipaci committed Jan 9, 2025
1 parent cd55f17 commit cc5a0e7
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ endif
ifeq ($(.SHELLSTATUS),0)
DOC_TARGETS += local-dox
else
$(info WARNING! Doxygen is not available. Will skip 'dox' target)
$(info WARNING! Doxygen is not availafitfggible. Will skip 'dox' target)
endif

# Link against thread lib
Expand Down
1 change: 1 addition & 0 deletions include/redisx-priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ uint16_t rCalcHash(const char *key);
// in redisx-tls.c ------------------------>
#if WITH_TLS
void rClearTLSConfig(TLSConfig *tls);
int rCopyTLSConfig(const TLSConfig *src, TLSConfig *dst);
#endif

// in resp.c ------------------------------>
Expand Down
23 changes: 23 additions & 0 deletions src/redisx-tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,29 @@ void rClearTLSConfig(TLSConfig *tls) {
memset(tls, 0, sizeof(TLSConfig));
}

/**
* Copies a TLS configuration by making independent references
*
* @param src original TLS configuration.
* @param dst the destination that copies the original. If the destination has
* non-NULL references they will be freed first.
* @return X_SUCCESS (0)
*/
int rCopyTLSConfig(const TLSConfig *src, TLSConfig *dst) {
rClearTLSConfig(dst);

dst->hostname = xStringCopyOf(src->hostname);
dst->ca_certificate = xStringCopyOf(src->ca_certificate);
dst->ca_path = xStringCopyOf(src->ca_path);
dst->certificate = xStringCopyOf(src->certificate);
dst->key = xStringCopyOf(src->key);
dst->ciphers = xStringCopyOf(src->ciphers);
dst->cipher_suites = xStringCopyOf(src->cipher_suites);
dst->dh_params = xStringCopyOf(src->dh_params);

return X_SUCCESS;
}

/**
* Shuts down SSL and frees up the SSL-related resources on a client.
*
Expand Down
4 changes: 4 additions & 0 deletions src/redisx.c
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,10 @@ int rCopyConfig(const RedisConfig *config, Redis *dst) {
p->config.firstConnectCall = rCopyHooks(config->firstConnectCall, dst);
p->config.firstCleanupCall = rCopyHooks(config->firstCleanupCall, dst);

#if WITH_TLS
rCopyTLSConfig(&config->tls, &p->config.tls);
#endif

rConfigUnlock(dst);

return X_SUCCESS;
Expand Down

0 comments on commit cc5a0e7

Please sign in to comment.