Skip to content

Commit bfdd7e5

Browse files
committed
deps: use quinn rustls re-export, try fixing tests
1 parent cb26f5a commit bfdd7e5

File tree

5 files changed

+45
-153
lines changed

5 files changed

+45
-153
lines changed

Cargo.lock

Lines changed: 0 additions & 123 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ rand = "0.8"
5858

5959
# networking
6060
quinn = "0.11.9"
61-
# (rustls needs to be the same version as the one used by quinn)
62-
rustls = { version = "0.23", default-features = false }
6361
rcgen = "0.12"
6462

6563
# benchmarking & profiling

msg-transport/Cargo.toml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,11 @@ thiserror = { workspace = true, optional = true }
2222

2323
# QUIC
2424
quinn = { workspace = true, optional = true }
25-
rustls = { workspace = true, optional = true, features = [
26-
"std",
27-
"aws_lc_rs",
28-
"tls12",
29-
] }
3025
rcgen = { workspace = true, optional = true }
3126

3227
[dev-dependencies]
3328
tracing-subscriber = "0.3"
3429

3530
[features]
3631
default = []
37-
quic = ["dep:quinn", "dep:rustls", "dep:rcgen", "dep:thiserror"]
32+
quic = ["dep:quinn", "dep:rcgen", "dep:thiserror"]

msg-transport/src/quic/mod.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,14 @@ impl Transport<SocketAddr> for Quic {
125125
let client_config = self.config.client_config.clone();
126126

127127
Box::pin(async move {
128+
debug!(target = %addr, "Initiating connection");
129+
128130
// This `"l"` seems necessary because an empty string is an invalid domain
129131
// name. While we don't use domain names, the underlying rustls library
130132
// is based upon the assumption that we do.
131-
let connection =
132-
endpoint.connect_with(client_config, addr, "l")?.await.map_err(Error::from)?;
133+
let connection = endpoint.connect_with(client_config, addr, "localhost")?.await?;
133134

134-
debug!("Connected to {}, opening stream", addr);
135+
debug!(target = %addr, "Connected, opening stream...");
135136

136137
// Open a bi-directional stream and return it. We'll think about multiplexing per topic
137138
// later.
@@ -158,7 +159,8 @@ impl Transport<SocketAddr> for Quic {
158159

159160
// Return a future that resolves to the output.
160161
return Poll::Ready(Box::pin(async move {
161-
let connection = connecting.await.map_err(Error::from)?;
162+
debug!(client = %peer, "Accepting connection...");
163+
let connection = connecting.await?;
162164
debug!(
163165
"Accepted connection from {}, opening stream",
164166
connection.remote_address()
@@ -238,7 +240,7 @@ mod tests {
238240
use super::*;
239241

240242
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
241-
async fn test_quic_connection() {
243+
async fn test_quic_connection_simple() {
242244
let _ = tracing_subscriber::fmt::try_init();
243245

244246
let config = Config::default();
@@ -252,7 +254,7 @@ mod tests {
252254
let (tx, rx) = oneshot::channel();
253255

254256
tokio::spawn(async move {
255-
tokio::time::sleep(Duration::from_secs(1)).await;
257+
// tokio::time::sleep(Duration::from_secs(1)).await;
256258

257259
let mut stream = server.accept().await.unwrap();
258260

msg-transport/src/quic/tls.rs

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
use std::sync::Arc;
22

3-
use quinn::crypto::rustls::{QuicClientConfig, QuicServerConfig};
4-
use rustls::{
5-
SignatureScheme,
6-
client::danger::{HandshakeSignatureValid, ServerCertVerified, ServerCertVerifier},
7-
pki_types::{CertificateDer, PrivateKeyDer},
3+
use quinn::{
4+
crypto::rustls::{QuicClientConfig, QuicServerConfig},
5+
rustls::{
6+
self, SignatureScheme,
7+
client::danger::{ServerCertVerified, ServerCertVerifier},
8+
pki_types::{CertificateDer, PrivateKeyDer},
9+
},
810
};
911

1012
use crate::quic::ALPN_PROTOCOL;
@@ -15,7 +17,7 @@ pub(crate) struct SkipServerVerification(Arc<rustls::crypto::CryptoProvider>);
1517

1618
impl SkipServerVerification {
1719
fn new() -> Arc<Self> {
18-
Arc::new(Self(Arc::new(rustls::crypto::aws_lc_rs::default_provider())))
20+
Arc::new(Self(Arc::new(rustls::crypto::ring::default_provider())))
1921
}
2022
}
2123

@@ -28,36 +30,54 @@ impl ServerCertVerifier for SkipServerVerification {
2830
_ocsp_response: &[u8],
2931
_now: rustls::pki_types::UnixTime,
3032
) -> Result<rustls::client::danger::ServerCertVerified, rustls::Error> {
33+
tracing::debug!(target = "quic.tls", "Skipping server verification");
3134
Ok(ServerCertVerified::assertion())
3235
}
3336

3437
fn verify_tls12_signature(
3538
&self,
36-
_message: &[u8],
37-
_cert: &rustls::pki_types::CertificateDer<'_>,
38-
_dss: &rustls::DigitallySignedStruct,
39+
message: &[u8],
40+
cert: &rustls::pki_types::CertificateDer<'_>,
41+
dss: &rustls::DigitallySignedStruct,
3942
) -> Result<rustls::client::danger::HandshakeSignatureValid, rustls::Error> {
40-
Ok(HandshakeSignatureValid::assertion())
43+
tracing::debug!(target = "quic.tls", "Verifying TLS 1.2 signature");
44+
rustls::crypto::verify_tls12_signature(
45+
message,
46+
cert,
47+
dss,
48+
&self.0.signature_verification_algorithms,
49+
)
4150
}
4251

4352
fn verify_tls13_signature(
4453
&self,
45-
_message: &[u8],
46-
_cert: &rustls::pki_types::CertificateDer<'_>,
47-
_dss: &rustls::DigitallySignedStruct,
54+
message: &[u8],
55+
cert: &rustls::pki_types::CertificateDer<'_>,
56+
dss: &rustls::DigitallySignedStruct,
4857
) -> Result<rustls::client::danger::HandshakeSignatureValid, rustls::Error> {
49-
Ok(HandshakeSignatureValid::assertion())
58+
tracing::debug!(target = "quic.tls", "Verifying TLS 1.3 signature");
59+
rustls::crypto::verify_tls13_signature(
60+
message,
61+
cert,
62+
dss,
63+
&self.0.signature_verification_algorithms,
64+
)
5065
}
5166

5267
fn supported_verify_schemes(&self) -> Vec<SignatureScheme> {
68+
tracing::debug!(
69+
target = "quic.tls",
70+
"Supported verify schemes: {:?}",
71+
self.0.signature_verification_algorithms.supported_schemes()
72+
);
5373
self.0.signature_verification_algorithms.supported_schemes()
5474
}
5575
}
5676

5777
/// Returns a TLS configuration that skips all server verification and doesn't do any client
5878
/// authentication, with the correct ALPN protocol.
5979
pub(crate) fn unsafe_client_config() -> QuicClientConfig {
60-
let provider = Arc::new(rustls::crypto::aws_lc_rs::default_provider());
80+
let provider = Arc::new(rustls::crypto::ring::default_provider());
6181

6282
let mut rustls_config = rustls::ClientConfig::builder_with_provider(provider)
6383
.with_protocol_versions(&[&rustls::version::TLS13])
@@ -76,7 +96,7 @@ pub(crate) fn unsafe_client_config() -> QuicClientConfig {
7696
/// the correct ALPN protocol.
7797
pub(crate) fn tls_server_config() -> QuicServerConfig {
7898
let (cert_chain, key_der) = self_signed_certificate();
79-
let provider = Arc::new(rustls::crypto::aws_lc_rs::default_provider());
99+
let provider = Arc::new(rustls::crypto::ring::default_provider());
80100

81101
let mut rustls_config = rustls::ServerConfig::builder_with_provider(provider)
82102
.with_protocol_versions(&[&rustls::version::TLS13])

0 commit comments

Comments
 (0)