Skip to content

Commit 6969fc5

Browse files
committed
Add an option to retrieve TLS errors
Signed-off-by: Mateusz Szczygieł <[email protected]>
1 parent 9596c7a commit 6969fc5

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

quinn-proto/src/connection/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2605,6 +2605,7 @@ impl Connection {
26052605
code: TransportErrorCode::crypto(0x6d),
26062606
frame: None,
26072607
reason: "transport parameters missing".into(),
2608+
tls_error: None,
26082609
})?;
26092610

26102611
if self.has_0rtt() {
@@ -2678,6 +2679,7 @@ impl Connection {
26782679
code: TransportErrorCode::crypto(0x6d),
26792680
frame: None,
26802681
reason: "transport parameters missing".into(),
2682+
tls_error: None,
26812683
})?;
26822684
self.handle_peer_params(params)?;
26832685
self.issue_first_cids(now);

quinn-proto/src/crypto/rustls.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ impl crypto::Session for TlsSession {
110110
code: TransportErrorCode::crypto(alert.into()),
111111
frame: None,
112112
reason: e.to_string(),
113+
tls_error: Some(e),
113114
}
114115
} else {
115116
TransportError::PROTOCOL_VIOLATION(format!("TLS error: {e}"))

quinn-proto/src/transport_error.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,20 @@ use crate::{
88
};
99

1010
/// Transport-level errors occur when a peer violates the protocol specification
11-
#[derive(Debug, Clone, Eq, PartialEq)]
11+
#[derive(Debug, Clone, PartialEq)]
1212
pub struct Error {
1313
/// Type of error
1414
pub code: Code,
1515
/// Frame type that triggered the error
1616
pub frame: Option<frame::FrameType>,
1717
/// Human-readable explanation of the reason
1818
pub reason: String,
19+
/// An underlying TLS layer error
20+
pub tls_error: Option<rustls::Error>,
1921
}
2022

23+
impl Eq for Error {}
24+
2125
impl fmt::Display for Error {
2226
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2327
self.code.fmt(f)?;
@@ -39,6 +43,7 @@ impl From<Code> for Error {
3943
code: x,
4044
frame: None,
4145
reason: "".to_string(),
46+
tls_error: None,
4247
}
4348
}
4449
}
@@ -79,6 +84,7 @@ macro_rules! errors {
7984
code: Code::$name,
8085
frame: None,
8186
reason: reason.into(),
87+
tls_error: None,
8288
}
8389
}
8490
)*

quinn/src/connection.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,6 +1078,7 @@ impl State {
10781078
code: proto::TransportErrorCode::INTERNAL_ERROR,
10791079
frame: None,
10801080
reason: "endpoint driver future was dropped".to_string(),
1081+
tls_error: None,
10811082
}));
10821083
}
10831084
Poll::Pending => {

0 commit comments

Comments
 (0)