summaryrefslogtreecommitdiff
path: root/examples/example-libevent-ssl.c
diff options
context:
space:
mode:
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;
}