#pragma once
#include <ssl_utils.h>
#include <pthread.h>
#include <tfe_future.h>
#include <tfe_utils.h>
#include <MESA/MESA_htable.h>
#include <event2/event.h>

struct keyring
{
	EVP_PKEY *key;
	X509 *cert;
	STACK_OF(X509) * chain;
};

struct key_keeper;

struct key_keeper * key_keeper_init(const char * profile, const char* section, void* logger);

void key_keeper_destroy(struct key_keeper *keeper);

struct keyring* key_keeper_release_keyring(future_result_t* result);

void key_keeper_free_keyring(struct keyring* cert);

void key_keeper_async_ask(struct future * f, struct key_keeper * keeper, const char* sni, int keyring_id, 
						X509 * origin_cert,  int is_cert_valid, struct event_base * evbase);

