Improve SSL cleanup handling. (#8589)
This solves the problem of /dev/random and /dev/urandom open file descriptors leaking to childs with some versions of OpenSSL.
This commit is contained in:
parent
fba391ae66
commit
ea1b48bd12
@ -870,6 +870,7 @@ void sentinelRunPendingScripts(void) {
|
|||||||
sj->pid = 0;
|
sj->pid = 0;
|
||||||
} else if (pid == 0) {
|
} else if (pid == 0) {
|
||||||
/* Child */
|
/* Child */
|
||||||
|
tlsCleanup();
|
||||||
execve(sj->argv[0],sj->argv,environ);
|
execve(sj->argv[0],sj->argv,environ);
|
||||||
/* If we are here an error occurred. */
|
/* If we are here an error occurred. */
|
||||||
_exit(2); /* Don't retry execution. */
|
_exit(2); /* Don't retry execution. */
|
||||||
|
@ -2715,6 +2715,7 @@ void makeThreadKillable(void);
|
|||||||
|
|
||||||
/* TLS stuff */
|
/* TLS stuff */
|
||||||
void tlsInit(void);
|
void tlsInit(void);
|
||||||
|
void tlsCleanup(void);
|
||||||
int tlsConfigure(redisTLSContextConfig *ctx_config);
|
int tlsConfigure(redisTLSContextConfig *ctx_config);
|
||||||
|
|
||||||
#define redisDebug(fmt, ...) \
|
#define redisDebug(fmt, ...) \
|
||||||
|
20
src/tls.c
20
src/tls.c
@ -147,7 +147,7 @@ void tlsInit(void) {
|
|||||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||||
OPENSSL_config(NULL);
|
OPENSSL_config(NULL);
|
||||||
#else
|
#else
|
||||||
OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CONFIG, NULL);
|
OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CONFIG|OPENSSL_INIT_ATFORK, NULL);
|
||||||
#endif
|
#endif
|
||||||
ERR_load_crypto_strings();
|
ERR_load_crypto_strings();
|
||||||
SSL_load_error_strings();
|
SSL_load_error_strings();
|
||||||
@ -164,6 +164,21 @@ void tlsInit(void) {
|
|||||||
pending_list = listCreate();
|
pending_list = listCreate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tlsCleanup(void) {
|
||||||
|
if (redis_tls_ctx) {
|
||||||
|
SSL_CTX_free(redis_tls_ctx);
|
||||||
|
redis_tls_ctx = NULL;
|
||||||
|
}
|
||||||
|
if (redis_tls_client_ctx) {
|
||||||
|
SSL_CTX_free(redis_tls_client_ctx);
|
||||||
|
redis_tls_client_ctx = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
|
||||||
|
OPENSSL_cleanup();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/* Create a *base* SSL_CTX using the SSL configuration provided. The base context
|
/* Create a *base* SSL_CTX using the SSL configuration provided. The base context
|
||||||
* includes everything that's common for both client-side and server-side connections.
|
* includes everything that's common for both client-side and server-side connections.
|
||||||
*/
|
*/
|
||||||
@ -948,6 +963,9 @@ sds connTLSGetPeerCert(connection *conn_) {
|
|||||||
void tlsInit(void) {
|
void tlsInit(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tlsCleanup(void) {
|
||||||
|
}
|
||||||
|
|
||||||
int tlsConfigure(redisTLSContextConfig *ctx_config) {
|
int tlsConfigure(redisTLSContextConfig *ctx_config) {
|
||||||
UNUSED(ctx_config);
|
UNUSED(ctx_config);
|
||||||
return C_OK;
|
return C_OK;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user