summaryrefslogtreecommitdiff
path: root/src/cli_common.h
diff options
context:
space:
mode:
authorfilipe oliveira <filipecosta.90@gmail.com>2020-10-28 06:00:54 +0000
committerGitHub <noreply@github.com>2020-10-28 08:00:54 +0200
commit39436b21527d878f23eef0bd64edbff47af073c5 (patch)
tree96a6e2384a2a6aa6a66102a45e421404dc505061 /src/cli_common.h
parent66037309c63c53a28c9553070a4557fabb84ed5a (diff)
downloadredis-39436b21527d878f23eef0bd64edbff47af073c5.tar.gz
TLS Support for redis-benchmark (#7959)
Diffstat (limited to 'src/cli_common.h')
-rw-r--r--src/cli_common.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/cli_common.h b/src/cli_common.h
new file mode 100644
index 000000000..700a834ce
--- /dev/null
+++ b/src/cli_common.h
@@ -0,0 +1,44 @@
+#ifndef __CLICOMMON_H
+#define __CLICOMMON_H
+
+#include <hiredis.h>
+
+typedef struct cliSSLconfig {
+ /* Requested SNI, or NULL */
+ char *sni;
+ /* CA Certificate file, or NULL */
+ char *cacert;
+ /* Directory where trusted CA certificates are stored, or NULL */
+ char *cacertdir;
+ /* Client certificate to authenticate with, or NULL */
+ char *cert;
+ /* Private key file to authenticate with, or NULL */
+ char *key;
+} cliSSLconfig;
+
+/* Wrapper around redisSecureConnection to avoid hiredis_ssl dependencies if
+ * not building with TLS support.
+ */
+int cliSecureConnection(redisContext *c, cliSSLconfig config, const char **err);
+
+/* Wrapper around hiredis to allow arbitrary reads and writes.
+ *
+ * We piggybacks on top of hiredis to achieve transparent TLS support,
+ * and use its internal buffers so it can co-exist with commands
+ * previously/later issued on the connection.
+ *
+ * Interface is close to enough to read()/write() so things should mostly
+ * work transparently.
+ */
+
+/* Write a raw buffer through a redisContext. If we already have something
+ * in the buffer (leftovers from hiredis operations) it will be written
+ * as well.
+ */
+ssize_t cliWriteConn(redisContext *c, const char *buf, size_t buf_len);
+
+/* Wrapper around OpenSSL (libssl and libcrypto) initialisation.
+ */
+int cliSecureInit();
+
+#endif /* __CLICOMMON_H */