AMQP-CPP/src/linux_tcp/sslerrorprinter.h

76 lines
1.3 KiB
C
Raw Normal View History

2021-07-13 17:23:08 +08:00
/**
* SslErrorPrinter.h
*
* Flushes the SSL error stack to a BIO.
* You can get at the string content via the data() and size() methods.
* After constructing an instance of this class, the SSL error stack
* is empty.
*
* @copyright 2021 copernica BV
*/
/**
* Include guard
*/
#pragma once
/**
* Dependencies
*/
#include "openssl.h"
#include <memory>
/**
* Begin namespace
*/
namespace AMQP {
/**
* Class declaration
*/
class SslErrorPrinter final
{
/**
* pointer to the BIO
* @var unique_ptr
*/
std::unique_ptr<::BIO, decltype(&::BIO_free)> _bio;
/**
* pointer to the (data, size) tuple
* @var ::BUF_MEM*
*/
::BUF_MEM *_bufmem = nullptr;
/**
* In case of a syscall error, the static string pointing to the error
* @var const char*
*/
const char *_strerror = nullptr;
public:
/**
* Constructor
2021-07-13 17:37:31 +08:00
* @param retval return value of SSL_get_error (must be a proper error)
2021-07-13 17:23:08 +08:00
* @throw std::bad_alloc if the BIO couldn't be allocated
*/
2021-07-13 17:37:31 +08:00
SslErrorPrinter(int retval);
2021-07-13 17:23:08 +08:00
/**
* data ptr
* @return const char *
*/
2021-07-13 17:37:31 +08:00
const char *data() const noexcept;
2021-07-13 17:23:08 +08:00
/**
* length of the string
* @return size_t
*/
2021-07-13 17:37:31 +08:00
std::size_t size() const noexcept;
2021-07-13 17:23:08 +08:00
};
2021-07-13 17:24:08 +08:00
/**
* End of namespace AMQP
*/
2021-07-13 17:23:08 +08:00
}