Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

quinn-proto v0.10.0 w/ rustls v0.21.0 #1515

Merged
merged 2 commits into from
Apr 1, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion bench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ bytes = "1"
hdrhistogram = { version = "7.2", default-features = false }
quinn = { path = "../quinn" }
rcgen = "0.10.0"
rustls = { version = "0.20", default-features = false, features = ["quic"] }
rustls = { version = "0.21.0", default-features = false, features = ["quic"] }
clap = { version = "3.2", features = ["derive"] }
tokio = { version = "1.0.1", features = ["rt", "sync"] }
tracing = "0.1.10"
Expand Down
2 changes: 1 addition & 1 deletion perf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ hdrhistogram = { version = "7.2", default-features = false }
quinn = { path = "../quinn" }
quinn-proto = { path = "../quinn-proto" }
rcgen = "0.10.0"
rustls = { version = "0.20", default-features = false, features = ["dangerous_configuration"] }
rustls = { version = "0.21.0", default-features = false, features = ["dangerous_configuration"] }
rustls-pemfile = "1.0.0"
serde = { version = "1.0", features = ["derive"], optional = true }
serde_json = { version = "1.0", optional = true }
Expand Down
4 changes: 2 additions & 2 deletions quinn-proto/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "quinn-proto"
version = "0.9.3"
version = "0.10.0"
edition = "2021"
rust-version = "1.59"
license = "MIT OR Apache-2.0"
Expand Down Expand Up @@ -30,7 +30,7 @@ bytes = "1"
rustc-hash = "1.1"
rand = "0.8"
ring = { version = "0.16.7", optional = true }
rustls = { version = "0.20.4", default-features = false, features = ["quic"], optional = true }
rustls = { version = "0.21.0", default-features = false, features = ["quic"], optional = true }
rustls-native-certs = { version = "0.6", optional = true }
slab = "0.4"
thiserror = "1.0.21"
Expand Down
32 changes: 19 additions & 13 deletions quinn-proto/src/crypto/rustls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ use ring::aead;
pub use rustls::Error;
use rustls::{
self,
quic::{
ClientQuicExt, HeaderProtectionKey, KeyChange, PacketKey, QuicExt, Secrets, ServerQuicExt,
Version,
},
Connection,
quic::{Connection, HeaderProtectionKey, KeyChange, PacketKey, Secrets, Version},
};

use crate::{
Expand All @@ -20,6 +16,15 @@ use crate::{
ConnectError, ConnectionId, Side, TransportError, TransportErrorCode,
};

impl From<Side> for rustls::Side {
fn from(s: Side) -> Self {
match s {
Side::Client => rustls::Side::Client,
Side::Server => rustls::Side::Server,
}
}
}

/// A rustls TLS session
pub struct TlsSession {
version: Version,
Expand Down Expand Up @@ -50,7 +55,7 @@ impl crypto::Session for TlsSession {
protocol: self.inner.alpn_protocol().map(|x| x.into()),
server_name: match self.inner {
Connection::Client(_) => None,
Connection::Server(ref session) => session.sni_hostname().map(|x| x.into()),
Connection::Server(ref session) => session.server_name().map(|x| x.into()),
},
}))
}
Expand Down Expand Up @@ -95,7 +100,7 @@ impl crypto::Session for TlsSession {
// connections.
let have_server_name = match self.inner {
Connection::Client(_) => false,
Connection::Server(ref session) => session.sni_hostname().is_some(),
Connection::Server(ref session) => session.server_name().is_some(),
};
if self.inner.alpn_protocol().is_some() || have_server_name || !self.is_handshaking() {
self.got_handshake_data = true;
Expand Down Expand Up @@ -180,7 +185,8 @@ impl crypto::Session for TlsSession {
) -> Result<(), ExportKeyingMaterialError> {
self.inner
.export_keying_material(output, label, Some(context))
.map_err(|_| ExportKeyingMaterialError)
cpu marked this conversation as resolved.
Show resolved Hide resolved
.map_err(|_| ExportKeyingMaterialError)?;
Ok(())
}
}

Expand Down Expand Up @@ -252,8 +258,8 @@ impl crypto::ClientConfig for rustls::ClientConfig {
version,
got_handshake_data: false,
next_secrets: None,
inner: Connection::Client(
rustls::ClientConnection::new_quic(
inner: rustls::quic::Connection::Client(
rustls::quic::ClientConnection::new(
self,
version,
server_name
Expand All @@ -278,8 +284,8 @@ impl crypto::ServerConfig for rustls::ServerConfig {
version,
got_handshake_data: false,
next_secrets: None,
inner: Connection::Server(
rustls::ServerConnection::new_quic(self, version, to_vec(params)).unwrap(),
inner: rustls::quic::Connection::Server(
rustls::quic::ServerConnection::new(self, version, to_vec(params)).unwrap(),
),
})
}
Expand Down Expand Up @@ -326,7 +332,7 @@ fn to_vec(params: &TransportParameters) -> Vec<u8> {
}

pub(crate) fn initial_keys(version: Version, dst_cid: &ConnectionId, side: Side) -> Keys {
let keys = rustls::quic::Keys::initial(version, dst_cid, side.is_client());
let keys = rustls::quic::Keys::initial(version, dst_cid, side.into());
Keys {
header: KeyPair {
local: Box::new(keys.local.header),
Expand Down
8 changes: 4 additions & 4 deletions quinn-proto/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use bytes::Bytes;
use hex_literal::hex;
use rand::RngCore;
use ring::hmac;
use rustls::internal::msgs::enums::AlertDescription;
use rustls::AlertDescription;
use tracing::info;

use super::*;
Expand Down Expand Up @@ -354,7 +354,7 @@ fn reject_self_signed_server_cert() {
pair.drive();
assert_matches!(pair.client_conn_mut(client_ch).poll(),
Some(Event::ConnectionLost { reason: ConnectionError::TransportError(ref error)})
if error.code == TransportErrorCode::crypto(AlertDescription::BadCertificate.get_u8()));
if error.code == TransportErrorCode::crypto(AlertDescription::UnknownCA.get_u8()));
}

#[test]
Expand All @@ -369,9 +369,9 @@ fn reject_missing_client_cert() {
.with_safe_default_kx_groups()
.with_protocol_versions(&[&rustls::version::TLS13])
.unwrap()
.with_client_cert_verifier(rustls::server::AllowAnyAuthenticatedClient::new(
.with_client_cert_verifier(Arc::new(rustls::server::AllowAnyAuthenticatedClient::new(
rustls::RootCertStore::empty(),
))
)))
.with_single_cert(vec![rustls::Certificate(cert)], key)
.unwrap();

Expand Down
2 changes: 1 addition & 1 deletion quinn-udp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ maintenance = { status = "experimental" }

[dependencies]
libc = "0.2.69"
proto = { package = "quinn-proto", path = "../quinn-proto", version = "0.9", default-features = false }
proto = { package = "quinn-proto", path = "../quinn-proto", version = "0.10", default-features = false }
socket2 = "0.4" # 0.5.1 has an MSRV of 1.63
tracing = "0.1.10"

Expand Down
4 changes: 2 additions & 2 deletions quinn/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ bytes = "1"
futures-io = { version = "0.3.19", optional = true }
rustc-hash = "1.1"
pin-project-lite = "0.2"
proto = { package = "quinn-proto", path = "../quinn-proto", version = "0.9", default-features = false }
rustls = { version = "0.20.3", default-features = false, features = ["quic"], optional = true }
proto = { package = "quinn-proto", path = "../quinn-proto", version = "0.10", default-features = false }
rustls = { version = "0.21.0", default-features = false, features = ["quic"], optional = true }
thiserror = "1.0.21"
tracing = "0.1.10"
tokio = { version = "1.13.0", features = ["sync"] }
Expand Down