完成ssl stream的流程梳理和接口定义。

This commit is contained in:
zhengchao
2018-08-23 19:46:38 +08:00
parent 7995af9c77
commit 18a6dda00f
7 changed files with 463 additions and 353 deletions

View File

@@ -4,15 +4,16 @@
#include <openssl/ssl.h>
#include <pthread.h>
struct cert{};
typedef struct cert cert_t;
struct cert
{
EVP_PKEY *key;
X509 *crt;
STACK_OF(X509) * chain;
};
struct cert_mgr;
struct cert_mgr * cert_manager_init(const char * profile);
void cert_mgr_async_get(struct future * future, struct cert_mgr * mgr, int keyring_id,
struct cert_mgr * cert_mgr_init(const char * profile, const char* section);
struct cert* cert_mgr_query_result_release_cert(future_result_t* result);
void cert_mgr_free_cert(struct cert* cert);
void cert_mgr_async_query(struct future * future, struct cert_mgr * mgr, int keyring_id,
X509 * origin_cert, struct event_base * evbase);
void cert_free(cert_t * cert);
#endif /* !CERT_H */

View File

@@ -1,7 +0,0 @@
#pragma once
struct sess_cache;
struct sess_cache * session_cache_init();
void session_cache_set(struct sess_cache * cache, struct sockaddr * addr,
socklen_t addrlen, const char * sni, SSL_SESSION * session);

View File

@@ -1,24 +1,36 @@
#pragma once
#include <event2/event.h>
#include <tfe_future.h>
#include <cert.h>
struct ssl_client_hello
struct ssl_stream;
struct ssl_mgr;
struct ssl_mgr* init_ssl_manager(const char* ini_profile, const char* section);
void destroy_ssl_manager(struct ssl_mgr* mgr);
struct ssl_chello
{
//client hello
int version;
char* sni;
char* cipher_suites;
};
struct ssl_client_hello* ssl_get_peek_result(future_result_t* result);
void ssl_free_peek_result(struct ssl_client_hello* client_hello);
struct ssl_chello* ssl_peek_result_release_chello(future_result_t* result);
void ssl_chello_free(struct ssl_chello* client_hello);
void ssl_async_peek_client_hello(struct future* future, evutil_socket_t fd, struct event_base *evbase);
void ssl_async_connect_origin(struct future* future, const struct ssl_client_hello* client_hello,
evutil_socket_t fd, const char* sni, struct event_base *evbase);
struct ssl_downstream * ssl_downstream_create();
void ssl_upstream_free(struct ssl_upstream * p);
void ssl_downstream_free(struct ssl_downstream * p);
struct ssl_stream* ssl_upstream_create_result_release_stream(future_result_t* result);
struct bufferevent* ssl_upstream_create_result_release_bev(future_result_t* result);
void ssl_async_upstream_create(struct future* future, struct ssl_mgr* mgr, const struct ssl_chello* chello, evutil_socket_t fd, struct event_base *evbase);
struct ssl_stream * ssl_downstream_create(struct ssl_mgr* mgr, struct ssl_chello* hello, struct cert* crt);
void ssl_stream_free_and_close_fd(struct ssl_stream* stream, struct event_base *evbase, evutil_socket_t fd);