#ifndef SSLUTIL_HPP #define SSLUTIL_HPP #include #include #include #include #include #include #include #include #include namespace sslutil { struct SSL_Deleter { void operator()(SSL *ssl) { SSL_free(ssl); } }; struct CTX_Deleter { void operator()(SSL_CTX *ctx) { SSL_CTX_free(ctx); } }; struct BIO_Deleter { void operator()(BIO *bio) { BIO_free(bio); } }; struct X509_Deleter { void operator()(X509 *x) { X509_free(x); } }; struct PKEY_Deleter { void operator()(EVP_PKEY *p) { EVP_PKEY_free(p); } }; using UniqueSSL = std::unique_ptr; using UniqueCTX = std::unique_ptr; using UniqueBIO = std::unique_ptr; using UniqueX509 = std::unique_ptr; using UniquePKEY = std::unique_ptr; struct ErrClearErrorOnExit { ~ErrClearErrorOnExit() { ERR_clear_error(); } }; // Return the OpenSSL error as a string. std::string error_string(); void clear_all_errors(); SSL_CTX *new_context(int verify); void ctx_load_dummy_cert(SSL_CTX *ctx); void ctx_load_cert_from_directory(SSL_CTX *ctx, const std::string &dir); } // namespace sslutil #endif // SSLUTIL_HPP