mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 15:27:42 +00:00
LibTLS: Implement build_alert()
This commit is contained in:
parent
adab43987d
commit
0da07c284e
2 changed files with 19 additions and 6 deletions
|
@ -279,8 +279,11 @@ void TLSv12::build_random(PacketBuilder& builder)
|
||||||
ssize_t TLSv12::handle_payload(const ByteBuffer& vbuffer)
|
ssize_t TLSv12::handle_payload(const ByteBuffer& vbuffer)
|
||||||
{
|
{
|
||||||
if (m_context.connection_status == ConnectionStatus::Established) {
|
if (m_context.connection_status == ConnectionStatus::Established) {
|
||||||
auto packet = build_alert(false, (u8)AlertDescription::NoRenegotiation);
|
dbg() << "Renegotiation attempt ignored";
|
||||||
write_packet(packet);
|
// FIXME: We should properly say "NoRenegotiation", but that causes a handshake failure
|
||||||
|
// so we just roll with it and pretend that we _did_ renegotiate
|
||||||
|
// This will cause issues when we decide to have long-lasting connections, but
|
||||||
|
// we do not have those at the moment :^)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
auto buffer = vbuffer;
|
auto buffer = vbuffer;
|
||||||
|
@ -530,6 +533,9 @@ ssize_t TLSv12::handle_payload(const ByteBuffer& vbuffer)
|
||||||
write_packet(packet);
|
write_packet(packet);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case Error::NeedMoreData:
|
||||||
|
// Ignore this, as it's not an "error"
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
dbg() << "Unknown TLS::Error with value " << payload_res;
|
dbg() << "Unknown TLS::Error with value " << payload_res;
|
||||||
ASSERT_NOT_REACHED();
|
ASSERT_NOT_REACHED();
|
||||||
|
|
|
@ -129,10 +129,17 @@ ByteBuffer TLSv12::build_hello()
|
||||||
|
|
||||||
ByteBuffer TLSv12::build_alert(bool critical, u8 code)
|
ByteBuffer TLSv12::build_alert(bool critical, u8 code)
|
||||||
{
|
{
|
||||||
dbg() << "FIXME: build_alert";
|
PacketBuilder builder(MessageType::Alert, (u16)m_context.version);
|
||||||
(void)critical;
|
builder.append((u8)(critical ? AlertLevel::Critical : AlertLevel::Warning));
|
||||||
(void)code;
|
builder.append(code);
|
||||||
return {};
|
|
||||||
|
if (critical)
|
||||||
|
m_context.critical_error = code;
|
||||||
|
|
||||||
|
auto packet = builder.build();
|
||||||
|
update_packet(packet);
|
||||||
|
|
||||||
|
return packet;
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteBuffer TLSv12::build_finished()
|
ByteBuffer TLSv12::build_finished()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue