Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions crates/stdlib/src/ssl/compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,8 @@ pub(super) enum SslError {
ZeroReturn,
/// Unexpected EOF without close_notify (protocol violation)
Eof,
/// Non-TLS data received before handshake completed
PreauthData,
/// Certificate verification error
CertVerification(rustls::CertificateError),
/// I/O error
Expand Down Expand Up @@ -562,6 +564,15 @@ impl SslError {
.upcast(),
SslError::ZeroReturn => create_ssl_zero_return_error(vm).upcast(),
SslError::Eof => create_ssl_eof_error(vm).upcast(),
SslError::PreauthData => {
// Non-TLS data received before handshake
Self::create_ssl_error_with_reason(
vm,
None,
"before TLS handshake with data",
"before TLS handshake with data",
)
}
SslError::CertVerification(cert_err) => {
// Use the proper cert verification error creator
create_ssl_cert_verification_error(vm, &cert_err).expect("unlikely to happen")
Expand Down Expand Up @@ -1245,6 +1256,12 @@ pub(super) fn ssl_do_handshake(
}
}

// InvalidMessage during handshake means non-TLS data was received
// before the handshake completed (e.g., HTTP request to TLS server)
if matches!(e, rustls::Error::InvalidMessage(_)) {
return Err(SslError::PreauthData);
}

// Certificate verification errors are already handled by from_rustls

return Err(SslError::from_rustls(e));
Expand Down
Loading