summaryrefslogtreecommitdiff
path: root/examples/example-libevent-ssl.c
diff options
context:
space:
mode:
authorYossi Gottlieb <yossigo@gmail.com>2020-05-22 14:10:08 +0300
committerYossi Gottlieb <yossigo@gmail.com>2020-05-24 23:37:47 +0300
commit190bca88d0635f1e53d9e39fc69f4f21b67a1baf (patch)
treefba00c2e786aaecee15d6169c8ba7353a2726320 /examples/example-libevent-ssl.c
parent8e0264cfd6889b73c241b60736fe96ba1322ee6e (diff)
New SSL API to replace redisSecureConnection().
Diffstat (limited to 'examples/example-libevent-ssl.c')
-rw-r--r--examples/example-libevent-ssl.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/examples/example-libevent-ssl.c b/examples/example-libevent-ssl.c
index 1021113..aac5770 100644
--- a/examples/example-libevent-ssl.c
+++ b/examples/example-libevent-ssl.c
@@ -52,13 +52,25 @@ int main (int argc, char **argv) {
const char *certKey = argv[5];
const char *caCert = argc > 5 ? argv[6] : NULL;
+ redisSSLContext *ssl;
+ redisSSLContextError ssl_error;
+
+ redisInitOpenSSL();
+
+ ssl = redisCreateSSLContext(caCert, NULL,
+ cert, certKey, NULL, &ssl_error);
+ if (!ssl) {
+ printf("Error: %s\n", redisSSLContextGetError(ssl_error));
+ return 1;
+ }
+
redisAsyncContext *c = redisAsyncConnect(hostname, port);
if (c->err) {
/* Let *c leak for now... */
printf("Error: %s\n", c->errstr);
return 1;
}
- if (redisSecureConnection(&c->c, caCert, cert, certKey, "sni") != REDIS_OK) {
+ if (redisInitiateSSLWithContext(&c->c, ssl) != REDIS_OK) {
printf("SSL Error!\n");
exit(1);
}
@@ -69,5 +81,7 @@ int main (int argc, char **argv) {
redisAsyncCommand(c, NULL, NULL, "SET key %b", value, nvalue);
redisAsyncCommand(c, getCallback, (char*)"end-1", "GET key");
event_base_dispatch(base);
+
+ redisFreeSSLContext(ssl);
return 0;
}