WIP TLS
This commit is contained in:
@@ -12,6 +12,10 @@
|
||||
#include <deque>
|
||||
#include <vector>
|
||||
|
||||
#ifdef WITH_OPENSSL
|
||||
#include <openssl/types.h>
|
||||
#endif
|
||||
|
||||
#include "../util/xxh_x86dispatch.h"
|
||||
#include "../util/robin_hood.h"
|
||||
#include "malloc_or_die.h"
|
||||
@@ -56,6 +60,12 @@ struct op_aes_xts_decrypt_t;
|
||||
void destroy_aes_xts_encrypt(op_aes_xts_encrypt_t *encrypt_ctx);
|
||||
void destroy_aes_xts_decrypt(op_aes_xts_decrypt_t *decrypt_ctx);
|
||||
|
||||
struct __attribute__((__packed__)) msgr_tls_record_hdr_t
|
||||
{
|
||||
uint8_t encrypted;
|
||||
uint32_t size;
|
||||
};
|
||||
|
||||
struct osd_client_t
|
||||
{
|
||||
uint64_t client_id = 0;
|
||||
@@ -78,6 +88,17 @@ struct osd_client_t
|
||||
msgr_rdma_connection_t *rdma_conn = NULL;
|
||||
#endif
|
||||
|
||||
#ifdef WITH_OPENSSL
|
||||
SSL *ssl_cli = NULL;
|
||||
BIO *write_to_ssl = NULL;
|
||||
// FIXME: use custom bio to avoid 1 more memory copy?
|
||||
BIO *read_from_ssl = NULL;
|
||||
uint8_t *ssl_out_buf = NULL;
|
||||
size_t ssl_out_buf_size = 0, ssl_out_buf_cap = 0;
|
||||
bool ssl_handshake_done = false;
|
||||
bool ssl_want_write = false;
|
||||
#endif
|
||||
|
||||
// Read state
|
||||
int read_ready = 0;
|
||||
osd_op_t *read_op = NULL;
|
||||
@@ -211,6 +232,11 @@ protected:
|
||||
int iothread_count = 0;
|
||||
int max_aes_xts_pool_size = 256;
|
||||
|
||||
std::string tls_cert;
|
||||
std::string tls_key;
|
||||
std::string osd_tls_ca;
|
||||
std::string client_tls_ca;
|
||||
|
||||
#ifdef WITH_RDMA
|
||||
bool use_rdma = true;
|
||||
bool use_rdmacm = false;
|
||||
@@ -227,6 +253,19 @@ protected:
|
||||
robin_hood::unordered_flat_map<rdma_cm_id*, rdmacm_connecting_t*> rdmacm_connecting;
|
||||
#endif
|
||||
|
||||
#ifdef WITH_OPENSSL
|
||||
SSL_CTX *ssl_ctx = NULL;
|
||||
std::string tls_cn;
|
||||
|
||||
void ssl_init(osd_client_t *cl, bool server_mode);
|
||||
bool ssl_do_handshake(osd_client_t *cl);
|
||||
bool ssl_do_encrypt(osd_client_t *cl);
|
||||
size_t ssl_do_encrypt_to(osd_client_t *cl, uint8_t *buf, size_t size);
|
||||
bool ssl_op_write_buf(osd_client_t *cl, uint8_t *src, size_t src_len, bool skip_csum, size_t & from, size_t & done);
|
||||
size_t ssl_op_copy_to(osd_client_t *cl, uint8_t *dst, size_t dst_len);
|
||||
void ssl_op_get_write_buffers(osd_client_t *cl, std::vector<iovec> & lst);
|
||||
#endif
|
||||
|
||||
std::vector<msgr_iothread_t*> iothreads;
|
||||
std::vector<uint64_t> read_ready_clients;
|
||||
std::vector<uint64_t> write_ready_clients;
|
||||
@@ -305,6 +344,9 @@ protected:
|
||||
void handle_send(int result, bool prev, bool more, osd_client_t *cl);
|
||||
size_t op_copy_to(osd_client_t *cl, uint8_t *dst, size_t dst_len);
|
||||
void op_get_write_buffers(osd_client_t *cl, std::vector<iovec> & lst);
|
||||
void next_write_op(osd_client_t *cl);
|
||||
bool op_write_buf(osd_client_t *cl, uint8_t *src, size_t src_len, uint8_t *dst, size_t dst_len, bool skip_csum, size_t & from, size_t & done);
|
||||
bool op_copy_data_to(osd_client_t *cl, uint8_t *dst, size_t dst_len, size_t & from, size_t & done);
|
||||
|
||||
void handle_read(int result, osd_client_t *cl);
|
||||
bool handle_read_buffer(osd_client_t *cl, uint8_t *curbuf, size_t bufsize);
|
||||
|
||||
Reference in New Issue
Block a user