Skip to content

Commit 835679c

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

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-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: 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: 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: Some(e),
113114
}
114115
} else {
115116
TransportError::PROTOCOL_VIOLATION(format!("TLS error: {e}"))

quinn-proto/src/transport_error.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,26 @@ 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)]
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: Option<rustls::Error>,
1921
}
2022

23+
impl PartialEq for Error {
24+
fn eq(&self, other: &Self) -> bool {
25+
self.code == other.code && self.frame == other.frame && self.reason == other.reason
26+
}
27+
}
28+
29+
impl Eq for Error {}
30+
2131
impl fmt::Display for Error {
2232
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2333
self.code.fmt(f)?;
@@ -39,6 +49,7 @@ impl From<Code> for Error {
3949
code: x,
4050
frame: None,
4151
reason: "".to_string(),
52+
tls: None,
4253
}
4354
}
4455
}
@@ -79,6 +90,7 @@ macro_rules! errors {
7990
code: Code::$name,
8091
frame: None,
8192
reason: reason.into(),
93+
tls: None,
8294
}
8395
}
8496
)*

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: None,
10811082
}));
10821083
}
10831084
Poll::Pending => {

0 commit comments

Comments
 (0)