Skip to content

Commit

Permalink
Only override context read/write funcs on SSL_connect success.
Browse files Browse the repository at this point in the history
Fixes #1233
  • Loading branch information
michael-grunder committed Apr 3, 2024
1 parent 2a7b8fa commit 19cfd60
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,23 +364,26 @@ static int redisSSLConnect(redisContext *c, SSL *ssl) {
return REDIS_ERR;
}

c->funcs = &redisContextSSLFuncs;
rssl->ssl = ssl;

SSL_set_mode(rssl->ssl, SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER);
SSL_set_fd(rssl->ssl, c->fd);
SSL_set_connect_state(rssl->ssl);

ERR_clear_error();

int rv = SSL_connect(rssl->ssl);
if (rv == 1) {
c->funcs = &redisContextSSLFuncs;
c->privctx = rssl;
return REDIS_OK;
}

rv = SSL_get_error(rssl->ssl, rv);
if (((c->flags & REDIS_BLOCK) == 0) &&
(rv == SSL_ERROR_WANT_READ || rv == SSL_ERROR_WANT_WRITE)) {
(rv == SSL_ERROR_WANT_READ || rv == SSL_ERROR_WANT_WRITE))
{
c->funcs = &redisContextSSLFuncs;
c->privctx = rssl;
return REDIS_OK;
}
Expand Down

0 comments on commit 19cfd60

Please sign in to comment.