summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Nunberg <mnunberg@users.noreply.github.com>2019-08-27 07:10:25 -0400
committerGitHub <noreply@github.com>2019-08-27 07:10:25 -0400
commit2020f6f329e6b9879e4da74ffe400d9ec311fac8 (patch)
treef0823bcb33abb4331c991b0ed80709e993590041
parentff4fa45422dc104f3377cdc3bc88d2d24ac2fcf3 (diff)
parentaacd4ccd7611da795b403ff5b4a24a1c4a0c49ef (diff)
Merge pull request #702 from yossigo/report-connect-errors
SSL: Properly report SSL_connect() errors.
-rw-r--r--sslio.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/sslio.c b/sslio.c
index 47064db..f2f50a8 100644
--- a/sslio.c
+++ b/sslio.c
@@ -5,6 +5,9 @@
#ifdef HIREDIS_SSL
#include <pthread.h>
#include <errno.h>
+#include <string.h>
+
+#include <openssl/err.h>
void __redisSetError(redisContext *c, int type, const char *str);
@@ -147,6 +150,7 @@ int redisSslCreate(redisContext *c, const char *capath, const char *certpath,
SSL_set_connect_state(s->ssl);
c->flags |= REDIS_SSL;
+ ERR_clear_error();
int rv = SSL_connect(c->ssl->ssl);
if (rv == 1) {
return REDIS_OK;
@@ -159,7 +163,15 @@ int redisSslCreate(redisContext *c, const char *capath, const char *certpath,
}
if (c->err == 0) {
- __redisSetError(c, REDIS_ERR_IO, "SSL_connect() failed");
+ char err[512];
+ if (rv == SSL_ERROR_SYSCALL)
+ snprintf(err,sizeof(err)-1,"SSL_connect failed: %s",strerror(errno));
+ else {
+ unsigned long e = ERR_peek_last_error();
+ snprintf(err,sizeof(err)-1,"SSL_connect failed: %s",
+ ERR_reason_error_string(e));
+ }
+ __redisSetError(c, REDIS_ERR_IO, err);
}
return REDIS_ERR;
}