diff options
author | zhenwei pi <pizhenwei@bytedance.com> | 2022-06-14 19:17:28 +0800 |
---|---|---|
committer | zhenwei pi <pizhenwei@bytedance.com> | 2022-08-22 15:11:25 +0800 |
commit | c4c02f80365e5f7a82efa6a4d4f247503f54a5d8 (patch) | |
tree | 66ad91caccc6597d54adae41551a1dce3907a5ce /src/connection.h | |
parent | 709b55b09dee2d22ae306d00b2c9ead1d382c044 (diff) | |
download | redis-c4c02f80365e5f7a82efa6a4d4f247503f54a5d8.tar.gz |
Introduce TLS specified APIs
Introduce .get_peer_cert, .get_ctx and .get_client_ctx for TLS, also
hide redis_tls_ctx & redis_tls_client_ctx.
Then outside could access the variables by connection API only:
- redis_tls_ctx -> connTypeGetCtx(CONN_TYPE_TLS)
- redis_tls_client_ctx -> connTypeGetClientCtx(CONN_TYPE_TLS)
Also remove connTLSGetPeerCert(), use connGetPeerCert() instead.
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
Diffstat (limited to 'src/connection.h')
-rw-r--r-- | src/connection.h | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/connection.h b/src/connection.h index dac4dc3ea..4cb74c4dc 100644 --- a/src/connection.h +++ b/src/connection.h @@ -95,6 +95,11 @@ typedef struct ConnectionType { /* pending data */ int (*has_pending_data)(void); int (*process_pending_data)(void); + + /* TLS specified methods */ + sds (*get_peer_cert)(struct connection *conn); + void* (*get_ctx)(void); + void* (*get_client_ctx)(void); } ConnectionType; struct connection { @@ -335,7 +340,17 @@ int connSendTimeout(connection *conn, long long ms); int connRecvTimeout(connection *conn, long long ms); /* Helpers for tls special considerations */ -sds connTLSGetPeerCert(connection *conn); +void *connTypeGetCtx(int type); +void *connTypeGetClientCtx(int type); + +/* Get cert for the secure connection */ +static inline sds connGetPeerCert(connection *conn) { + if (conn->type->get_peer_cert) { + return conn->type->get_peer_cert(conn); + } + + return NULL; +} /* Initialize the redis connection framework */ int connTypeInitialize(); |