61 lines
1.1 KiB
C++

#pragma once
#include <openssl/types.h>
#include "ehs/EHS.h"
#include "ehs/Str.h"
#include "TCP.h"
#include "Request.h"
#include "Response.h"
typedef struct ssl_ctx_st SSL_CTX;
typedef struct ssl_st SSL;
namespace ehs
{
/// A class for handling the HTTP(S) TCP socket layer.
class EHS_LIB_IO SSL : public TCP
{
private:
bool server;
SSL_CTX* ctx;
::SSL* sslHdl;
X509 *cert;
EVP_PKEY* pkey;
public:
~SSL() override;
SSL();
SSL(const IP &type, const bool &server);
SSL(TCP&& tcp) noexcept;
SSL(const TCP& tcp);
SSL(const SSL& ssl);
SSL& operator=(const SSL& ssl);
void Initialize() override;
void Release() override;
void Listen() override;
SSL* Accept() override;
void Connect(Str_8 address, const UInt_16 &port) override;
UInt_64 Send(const Byte* buffer, const UInt_32 size) override;
UInt_64 Receive(Byte* buffer, const UInt_32 size) override;
void UseCertificate(const Char_8* data, const UInt_32 &size);
void UsePrivateKey(const Char_8* data, const UInt_32 &size);
bool IsValid();
};
}