2023-12-17 03:29:08 -08:00
|
|
|
#pragma once
|
|
|
|
|
2024-01-14 09:38:57 -08:00
|
|
|
#include "ehs/EHS.h"
|
|
|
|
#include "ehs/Str.h"
|
2023-12-17 03:29:08 -08:00
|
|
|
#include "TCP.h"
|
|
|
|
#include "Request.h"
|
|
|
|
#include "Response.h"
|
|
|
|
|
|
|
|
typedef struct ssl_ctx_st SSL_CTX;
|
|
|
|
typedef struct ssl_st SSL;
|
|
|
|
|
2023-12-17 15:56:13 -08:00
|
|
|
namespace ehs
|
2023-12-17 03:29:08 -08:00
|
|
|
{
|
|
|
|
/// A class for handling the HTTP(S) TCP socket layer.
|
|
|
|
class SSL : public TCP
|
|
|
|
{
|
|
|
|
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();
|
|
|
|
};
|
|
|
|
}
|