2024-02-05 22:25:30 -08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#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.
|
2024-07-24 01:36:20 -07:00
|
|
|
class EHS_LIB_IO SSL : public TCP
|
2024-02-05 22:25:30 -08:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
SSL_CTX* ctx;
|
|
|
|
::SSL* sslHdl;
|
|
|
|
|
|
|
|
public:
|
|
|
|
~SSL() override;
|
|
|
|
|
|
|
|
SSL();
|
|
|
|
|
|
|
|
SSL(const AddrType type);
|
|
|
|
|
|
|
|
SSL(TCP&& tcp) noexcept;
|
|
|
|
|
|
|
|
SSL(const TCP& tcp);
|
|
|
|
|
|
|
|
SSL(const SSL& ssl);
|
|
|
|
|
|
|
|
SSL& operator=(const SSL& ssl);
|
|
|
|
|
|
|
|
void Initialize() override;
|
|
|
|
|
|
|
|
void Release() override;
|
|
|
|
|
|
|
|
void Bind(const Str_8& address, unsigned short port) override;
|
|
|
|
|
|
|
|
SSL* Accept() override;
|
|
|
|
|
|
|
|
void Connect(const Str_8& address, const UInt_16 port) override;
|
|
|
|
|
|
|
|
UInt_64 Send(const Byte* const buffer, const UInt_32 size) override;
|
|
|
|
|
|
|
|
UInt_64 Receive(Byte* const buffer, const UInt_32 size) override;
|
|
|
|
|
|
|
|
void UseCertificate(const Byte* data, const UInt_64 size);
|
|
|
|
|
|
|
|
void UsePrivateKey(const Byte* data, const UInt_64 size);
|
|
|
|
|
|
|
|
bool IsValid();
|
|
|
|
};
|
|
|
|
}
|