mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:17:46 +00:00
LibTLS: Avoid busy-wait between ClientHello and ServerHello
This commit also adds a timeout timer to cancel the connection if the server does not respond to the hello request in 10 seconds.
This commit is contained in:
parent
e5e8e8ab96
commit
d54d2892a9
5 changed files with 52 additions and 15 deletions
|
@ -142,6 +142,7 @@ enum class Error : i8 {
|
|||
FeatureNotSupported = -17,
|
||||
DecryptionFailed = -20,
|
||||
NeedMoreData = -21,
|
||||
TimedOut = -22,
|
||||
};
|
||||
|
||||
enum class AlertLevel : u8 {
|
||||
|
@ -293,6 +294,8 @@ struct Context {
|
|||
StringView negotiated_alpn;
|
||||
|
||||
size_t send_retries { 0 };
|
||||
|
||||
time_t handshake_initiation_timestamp { 0 };
|
||||
};
|
||||
|
||||
class TLSv12 : public Core::Socket {
|
||||
|
@ -335,7 +338,7 @@ public:
|
|||
ByteBuffer read(size_t max_size);
|
||||
|
||||
bool write(const ByteBuffer& buffer);
|
||||
void alert(bool critical, u8 code);
|
||||
void alert(AlertLevel, AlertDescription);
|
||||
|
||||
bool can_read_line() const { return m_context.application_buffer.size() && memchr(m_context.application_buffer.data(), '\n', m_context.application_buffer.size()); }
|
||||
bool can_read() const { return m_context.application_buffer.size() > 0; }
|
||||
|
@ -467,7 +470,10 @@ private:
|
|||
OwnPtr<Crypto::Cipher::AESCipher::CBCMode> m_aes_local;
|
||||
OwnPtr<Crypto::Cipher::AESCipher::CBCMode> m_aes_remote;
|
||||
|
||||
bool m_has_scheduled_write_flush = false;
|
||||
bool m_has_scheduled_write_flush { false };
|
||||
i32 m_max_wait_time_for_handshake_in_seconds { 10 };
|
||||
|
||||
RefPtr<Core::Timer> m_handshake_timeout_timer;
|
||||
};
|
||||
|
||||
namespace Constants {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue