2017-11-27 13:10:21 +00:00
|
|
|
#ifndef REDIS_SSLIO_H
|
|
|
|
#define REDIS_SSLIO_H
|
|
|
|
|
|
|
|
|
2018-01-08 21:07:10 +00:00
|
|
|
#ifndef HIREDIS_SSL
|
2017-11-27 13:10:21 +00:00
|
|
|
typedef struct redisSsl {
|
2018-01-08 21:07:10 +00:00
|
|
|
size_t lastLen;
|
|
|
|
int wantRead;
|
|
|
|
int pendingWrite;
|
2017-11-27 13:10:21 +00:00
|
|
|
} redisSsl;
|
2018-01-08 21:07:10 +00:00
|
|
|
static inline void redisFreeSsl(redisSsl *ssl) {
|
|
|
|
(void)ssl;
|
2017-11-27 13:10:21 +00:00
|
|
|
}
|
2018-01-08 21:07:10 +00:00
|
|
|
static inline int redisSslCreate(struct redisContext *c, const char *ca,
|
2018-12-20 14:26:24 +00:00
|
|
|
const char *cert, const char *key, const char *servername) {
|
|
|
|
(void)c;(void)ca;(void)cert;(void)key;(void)servername;
|
2017-11-27 13:10:21 +00:00
|
|
|
return REDIS_ERR;
|
|
|
|
}
|
2018-01-08 21:07:10 +00:00
|
|
|
static inline int redisSslRead(struct redisContext *c, char *s, size_t n) {
|
|
|
|
(void)c;(void)s;(void)n;
|
2017-11-27 13:10:21 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2018-01-08 21:07:10 +00:00
|
|
|
static inline int redisSslWrite(struct redisContext *c) {
|
|
|
|
(void)c;
|
2017-11-27 13:10:21 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#include <openssl/ssl.h>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This file contains routines for HIREDIS' SSL
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef struct redisSsl {
|
|
|
|
SSL *ssl;
|
|
|
|
SSL_CTX *ctx;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* SSL_write() requires to be called again with the same arguments it was
|
|
|
|
* previously called with in the event of an SSL_read/SSL_write situation
|
|
|
|
*/
|
|
|
|
size_t lastLen;
|
2017-11-27 20:49:28 +00:00
|
|
|
|
|
|
|
/** Whether the SSL layer requires read (possibly before a write) */
|
|
|
|
int wantRead;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether a write was requested prior to a read. If set, the write()
|
|
|
|
* should resume whenever a read takes place, if possible
|
|
|
|
*/
|
|
|
|
int pendingWrite;
|
2017-11-27 13:10:21 +00:00
|
|
|
} redisSsl;
|
|
|
|
|
|
|
|
struct redisContext;
|
|
|
|
|
|
|
|
void redisFreeSsl(redisSsl *);
|
|
|
|
int redisSslCreate(struct redisContext *c, const char *caPath,
|
2018-12-20 14:26:24 +00:00
|
|
|
const char *certPath, const char *keyPath, const char *servername);
|
2017-11-27 13:10:21 +00:00
|
|
|
|
|
|
|
int redisSslRead(struct redisContext *c, char *buf, size_t bufcap);
|
|
|
|
int redisSslWrite(struct redisContext *c);
|
|
|
|
|
2018-01-08 21:07:10 +00:00
|
|
|
#endif /* HIREDIS_SSL */
|
2017-11-27 13:10:21 +00:00
|
|
|
#endif /* HIREDIS_SSLIO_H */
|