summaryrefslogtreecommitdiff
path: root/hiredis_ssl.h
diff options
context:
space:
mode:
authorMichael Grunder <michael.grunder@gmail.com>2022-08-15 17:19:51 -0700
committerGitHub <noreply@github.com>2022-08-15 17:19:51 -0700
commit367a82bf02e8f3e198464edcb47fbba78b4d5824 (patch)
tree028b4342dbf16aef42293db409b69d91eec857c3 /hiredis_ssl.h
parentdd7979ac10a2bbaa06501512dcf22731af7b3fcc (diff)
parent71119a71d71d3c07bb9223de1ac5b4f97db3de0f (diff)
Merge pull request #1085 from stanhu/ssl-improve-options-setting
Make it possible to set SSL verify mode
Diffstat (limited to 'hiredis_ssl.h')
-rw-r--r--hiredis_ssl.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/hiredis_ssl.h b/hiredis_ssl.h
index e3d3e1c..26bc9e9 100644
--- a/hiredis_ssl.h
+++ b/hiredis_ssl.h
@@ -61,6 +61,27 @@ typedef enum {
REDIS_SSL_CTX_OS_CERT_ADD_FAILED /* Failed to add CA certificates obtained from system to the SSL context */
} redisSSLContextError;
+/* Constants that mirror OpenSSL's verify modes. By default,
+ * REDIS_SSL_VERIFY_PEER is used with redisCreateSSLContext().
+ * Some Redis clients disable peer verification if there are no
+ * certificates specified.
+ */
+#define REDIS_SSL_VERIFY_NONE 0x00
+#define REDIS_SSL_VERIFY_PEER 0x01
+#define REDIS_SSL_VERIFY_FAIL_IF_NO_PEER_CERT 0x02
+#define REDIS_SSL_VERIFY_CLIENT_ONCE 0x04
+#define REDIS_SSL_VERIFY_POST_HANDSHAKE 0x08
+
+/* Options to create an OpenSSL context. */
+typedef struct {
+ const char *cacert_filename;
+ const char *capath;
+ const char *cert_filename;
+ const char *private_key_filename;
+ const char *server_name;
+ int verify_mode;
+} redisSSLOptions;
+
/**
* Return the error message corresponding with the specified error code.
*/
@@ -102,6 +123,18 @@ redisSSLContext *redisCreateSSLContext(const char *cacert_filename, const char *
const char *server_name, redisSSLContextError *error);
/**
+ * Helper function to initialize an OpenSSL context that can be used
+ * to initiate SSL connections. This is a more extensible version of redisCreateSSLContext().
+ *
+ * options contains a structure of SSL options to use.
+ *
+ * If error is non-null, it will be populated in case the context creation fails
+ * (returning a NULL).
+*/
+redisSSLContext *redisCreateSSLContextWithOptions(redisSSLOptions *options,
+ redisSSLContextError *error);
+
+/**
* Free a previously created OpenSSL context.
*/
void redisFreeSSLContext(redisSSLContext *redis_ssl_ctx);