mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-29 02:50:26 +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
Notes:
sideshowbarker
2024-07-18 20:53:30 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/d6d6750dd81 Pull-request: https://github.com/SerenityOS/serenity/pull/6085
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) {
|
||||
m_context.SNI = String { (const char*)buffer.offset_pointer(res + 5), sni_host_length };
|
||||
dbgln("server name indicator: {}", m_context.SNI);
|
||||
m_context.extensions.SNI = String { (const char*)buffer.offset_pointer(res + 5), sni_host_length };
|
||||
dbgln("server name indicator: {}", m_context.extensions.SNI);
|
||||
}
|
||||
} else if (extension_type == HandshakeExtension::ApplicationLayerProtocolNegotiation && m_context.alpn.size()) {
|
||||
if (buffer.size() - res > 2) {
|
||||
|
|
|
@ -86,8 +86,8 @@ ByteBuffer TLSv12::build_hello()
|
|||
|
||||
// set SNI if we have one
|
||||
auto sni_length = 0;
|
||||
if (!m_context.SNI.is_null())
|
||||
sni_length = m_context.SNI.length();
|
||||
if (!m_context.extensions.SNI.is_null())
|
||||
sni_length = m_context.extensions.SNI.length();
|
||||
|
||||
if (sni_length)
|
||||
extension_length += sni_length + 9;
|
||||
|
@ -105,7 +105,7 @@ ByteBuffer TLSv12::build_hello()
|
|||
builder.append((u8)0);
|
||||
// SNI host length + value
|
||||
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) {
|
||||
|
|
|
@ -667,13 +667,13 @@ void TLSv12::try_disambiguate_error() const
|
|||
switch ((AlertDescription)m_context.critical_error) {
|
||||
case AlertDescription::HandshakeFailure:
|
||||
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 {
|
||||
dbgln("- Unknown internal issue");
|
||||
}
|
||||
break;
|
||||
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;
|
||||
case AlertDescription::ProtocolVersion:
|
||||
dbgln("- The server refused to negotiate with TLS 1.2 :(");
|
||||
|
|
|
@ -242,7 +242,10 @@ struct Context {
|
|||
|
||||
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 };
|
||||
|
||||
|
@ -278,7 +281,7 @@ public:
|
|||
dbgln("invalid state for set_sni");
|
||||
return;
|
||||
}
|
||||
m_context.SNI = sni;
|
||||
m_context.extensions.SNI = sni;
|
||||
}
|
||||
|
||||
Optional<Certificate> parse_asn1(ReadonlyBytes, bool client_cert = false) const;
|
||||
|
|
Loading…
Reference in a new issue