mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:37:45 +00:00
LibTLS: Move TLS extensions to a separate 'extensions' struct
This has no behavioural effect.
This commit is contained in:
parent
22d13d8b1a
commit
d6d6750dd8
4 changed files with 12 additions and 9 deletions
|
@ -163,8 +163,8 @@ ssize_t TLSv12::handle_hello(ReadonlyBytes buffer, WritePacketStage& write_packe
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sni_host_length) {
|
if (sni_host_length) {
|
||||||
m_context.SNI = String { (const char*)buffer.offset_pointer(res + 5), sni_host_length };
|
m_context.extensions.SNI = String { (const char*)buffer.offset_pointer(res + 5), sni_host_length };
|
||||||
dbgln("server name indicator: {}", m_context.SNI);
|
dbgln("server name indicator: {}", m_context.extensions.SNI);
|
||||||
}
|
}
|
||||||
} else if (extension_type == HandshakeExtension::ApplicationLayerProtocolNegotiation && m_context.alpn.size()) {
|
} else if (extension_type == HandshakeExtension::ApplicationLayerProtocolNegotiation && m_context.alpn.size()) {
|
||||||
if (buffer.size() - res > 2) {
|
if (buffer.size() - res > 2) {
|
||||||
|
|
|
@ -86,8 +86,8 @@ ByteBuffer TLSv12::build_hello()
|
||||||
|
|
||||||
// set SNI if we have one
|
// set SNI if we have one
|
||||||
auto sni_length = 0;
|
auto sni_length = 0;
|
||||||
if (!m_context.SNI.is_null())
|
if (!m_context.extensions.SNI.is_null())
|
||||||
sni_length = m_context.SNI.length();
|
sni_length = m_context.extensions.SNI.length();
|
||||||
|
|
||||||
if (sni_length)
|
if (sni_length)
|
||||||
extension_length += sni_length + 9;
|
extension_length += sni_length + 9;
|
||||||
|
@ -105,7 +105,7 @@ ByteBuffer TLSv12::build_hello()
|
||||||
builder.append((u8)0);
|
builder.append((u8)0);
|
||||||
// SNI host length + value
|
// SNI host length + value
|
||||||
builder.append((u16)sni_length);
|
builder.append((u16)sni_length);
|
||||||
builder.append((const u8*)m_context.SNI.characters(), sni_length);
|
builder.append((const u8*)m_context.extensions.SNI.characters(), sni_length);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (alpn_length) {
|
if (alpn_length) {
|
||||||
|
|
|
@ -667,13 +667,13 @@ void TLSv12::try_disambiguate_error() const
|
||||||
switch ((AlertDescription)m_context.critical_error) {
|
switch ((AlertDescription)m_context.critical_error) {
|
||||||
case AlertDescription::HandshakeFailure:
|
case AlertDescription::HandshakeFailure:
|
||||||
if (!m_context.cipher_spec_set) {
|
if (!m_context.cipher_spec_set) {
|
||||||
dbgln("- No cipher suite in common with {}", m_context.SNI);
|
dbgln("- No cipher suite in common with {}", m_context.extensions.SNI);
|
||||||
} else {
|
} else {
|
||||||
dbgln("- Unknown internal issue");
|
dbgln("- Unknown internal issue");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case AlertDescription::InsufficientSecurity:
|
case AlertDescription::InsufficientSecurity:
|
||||||
dbgln("- No cipher suite in common with {} (the server is oh so secure)", m_context.SNI);
|
dbgln("- No cipher suite in common with {} (the server is oh so secure)", m_context.extensions.SNI);
|
||||||
break;
|
break;
|
||||||
case AlertDescription::ProtocolVersion:
|
case AlertDescription::ProtocolVersion:
|
||||||
dbgln("- The server refused to negotiate with TLS 1.2 :(");
|
dbgln("- The server refused to negotiate with TLS 1.2 :(");
|
||||||
|
|
|
@ -242,7 +242,10 @@ struct Context {
|
||||||
|
|
||||||
bool is_child { false };
|
bool is_child { false };
|
||||||
|
|
||||||
String SNI; // I hate your existence
|
struct {
|
||||||
|
// Server Name Indicator
|
||||||
|
String SNI; // I hate your existence
|
||||||
|
} extensions;
|
||||||
|
|
||||||
u8 request_client_certificate { 0 };
|
u8 request_client_certificate { 0 };
|
||||||
|
|
||||||
|
@ -278,7 +281,7 @@ public:
|
||||||
dbgln("invalid state for set_sni");
|
dbgln("invalid state for set_sni");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_context.SNI = sni;
|
m_context.extensions.SNI = sni;
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<Certificate> parse_asn1(ReadonlyBytes, bool client_cert = false) const;
|
Optional<Certificate> parse_asn1(ReadonlyBytes, bool client_cert = false) const;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue