aboutsummaryrefslogtreecommitdiff
path: root/examples/redis-unstable/deps/hiredis/hiredis_ssl.h
diff options
context:
space:
mode:
authorMitja Felicijan <mitja.felicijan@gmail.com>2026-01-21 22:40:55 +0100
committerMitja Felicijan <mitja.felicijan@gmail.com>2026-01-21 22:40:55 +0100
commit5d8dfe892a2ea89f706ee140c3bdcfd89fe03fda (patch)
tree1acdfa5220cd13b7be43a2a01368e80d306473ca /examples/redis-unstable/deps/hiredis/hiredis_ssl.h
parentc7ab12bba64d9c20ccd79b132dac475f7bc3923e (diff)
downloadcrep-5d8dfe892a2ea89f706ee140c3bdcfd89fe03fda.tar.gz
Add Redis source code for testing
Diffstat (limited to 'examples/redis-unstable/deps/hiredis/hiredis_ssl.h')
-rw-r--r--examples/redis-unstable/deps/hiredis/hiredis_ssl.h163
1 files changed, 163 insertions, 0 deletions
diff --git a/examples/redis-unstable/deps/hiredis/hiredis_ssl.h b/examples/redis-unstable/deps/hiredis/hiredis_ssl.h
new file mode 100644
index 0000000..5f92cca
--- /dev/null
+++ b/examples/redis-unstable/deps/hiredis/hiredis_ssl.h
@@ -0,0 +1,163 @@
1
2/*
3 * Copyright (c) 2019, Redis Labs
4 *
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
9 *
10 * * Redistributions of source code must retain the above copyright notice,
11 * this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * * Neither the name of Redis nor the names of its contributors may be used
16 * to endorse or promote products derived from this software without
17 * specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#ifndef __HIREDIS_SSL_H
33#define __HIREDIS_SSL_H
34
35#ifdef __cplusplus
36extern "C" {
37#endif
38
39/* This is the underlying struct for SSL in ssl.h, which is not included to
40 * keep build dependencies short here.
41 */
42struct ssl_st;
43
44/* A wrapper around OpenSSL SSL_CTX to allow easy SSL use without directly
45 * calling OpenSSL.
46 */
47typedef struct redisSSLContext redisSSLContext;
48
49/**
50 * Initialization errors that redisCreateSSLContext() may return.
51 */
52
53typedef enum {
54 REDIS_SSL_CTX_NONE = 0, /* No Error */
55 REDIS_SSL_CTX_CREATE_FAILED, /* Failed to create OpenSSL SSL_CTX */
56 REDIS_SSL_CTX_CERT_KEY_REQUIRED, /* Client cert and key must both be specified or skipped */
57 REDIS_SSL_CTX_CA_CERT_LOAD_FAILED, /* Failed to load CA Certificate or CA Path */
58 REDIS_SSL_CTX_CLIENT_CERT_LOAD_FAILED, /* Failed to load client certificate */
59 REDIS_SSL_CTX_CLIENT_DEFAULT_CERT_FAILED, /* Failed to set client default certificate directory */
60 REDIS_SSL_CTX_PRIVATE_KEY_LOAD_FAILED, /* Failed to load private key */
61 REDIS_SSL_CTX_OS_CERTSTORE_OPEN_FAILED, /* Failed to open system certificate store */
62 REDIS_SSL_CTX_OS_CERT_ADD_FAILED /* Failed to add CA certificates obtained from system to the SSL context */
63} redisSSLContextError;
64
65/* Constants that mirror OpenSSL's verify modes. By default,
66 * REDIS_SSL_VERIFY_PEER is used with redisCreateSSLContext().
67 * Some Redis clients disable peer verification if there are no
68 * certificates specified.
69 */
70#define REDIS_SSL_VERIFY_NONE 0x00
71#define REDIS_SSL_VERIFY_PEER 0x01
72#define REDIS_SSL_VERIFY_FAIL_IF_NO_PEER_CERT 0x02
73#define REDIS_SSL_VERIFY_CLIENT_ONCE 0x04
74#define REDIS_SSL_VERIFY_POST_HANDSHAKE 0x08
75
76/* Options to create an OpenSSL context. */
77typedef struct {
78 const char *cacert_filename;
79 const char *capath;
80 const char *cert_filename;
81 const char *private_key_filename;
82 const char *server_name;
83 int verify_mode;
84} redisSSLOptions;
85
86/**
87 * Return the error message corresponding with the specified error code.
88 */
89
90const char *redisSSLContextGetError(redisSSLContextError error);
91
92/**
93 * Helper function to initialize the OpenSSL library.
94 *
95 * OpenSSL requires one-time initialization before it can be used. Callers should
96 * call this function only once, and only if OpenSSL is not directly initialized
97 * elsewhere.
98 */
99int redisInitOpenSSL(void);
100
101/**
102 * Helper function to initialize an OpenSSL context that can be used
103 * to initiate SSL connections.
104 *
105 * cacert_filename is an optional name of a CA certificate/bundle file to load
106 * and use for validation.
107 *
108 * capath is an optional directory path where trusted CA certificate files are
109 * stored in an OpenSSL-compatible structure.
110 *
111 * cert_filename and private_key_filename are optional names of a client side
112 * certificate and private key files to use for authentication. They need to
113 * be both specified or omitted.
114 *
115 * server_name is an optional and will be used as a server name indication
116 * (SNI) TLS extension.
117 *
118 * If error is non-null, it will be populated in case the context creation fails
119 * (returning a NULL).
120 */
121
122redisSSLContext *redisCreateSSLContext(const char *cacert_filename, const char *capath,
123 const char *cert_filename, const char *private_key_filename,
124 const char *server_name, redisSSLContextError *error);
125
126/**
127 * Helper function to initialize an OpenSSL context that can be used
128 * to initiate SSL connections. This is a more extensible version of redisCreateSSLContext().
129 *
130 * options contains a structure of SSL options to use.
131 *
132 * If error is non-null, it will be populated in case the context creation fails
133 * (returning a NULL).
134*/
135redisSSLContext *redisCreateSSLContextWithOptions(redisSSLOptions *options,
136 redisSSLContextError *error);
137
138/**
139 * Free a previously created OpenSSL context.
140 */
141void redisFreeSSLContext(redisSSLContext *redis_ssl_ctx);
142
143/**
144 * Initiate SSL on an existing redisContext.
145 *
146 * This is similar to redisInitiateSSL() but does not require the caller
147 * to directly interact with OpenSSL, and instead uses a redisSSLContext
148 * previously created using redisCreateSSLContext().
149 */
150
151int redisInitiateSSLWithContext(redisContext *c, redisSSLContext *redis_ssl_ctx);
152
153/**
154 * Initiate SSL/TLS negotiation on a provided OpenSSL SSL object.
155 */
156
157int redisInitiateSSL(redisContext *c, struct ssl_st *ssl);
158
159#ifdef __cplusplus
160}
161#endif
162
163#endif /* __HIREDIS_SSL_H */