Skip to content

Commit 72a0004

Browse files
build(deps): update s2n-tls requirement from =0.0.39 to =0.0.41 (#2031)
Updates the requirements on [s2n-tls](https://github.com/aws/s2n-tls) to permit the latest version. - [Release notes](https://github.com/aws/s2n-tls/releases) - [Commits](https://github.com/aws/s2n-tls/commits) --- updated-dependencies: - dependency-name: s2n-tls dependency-type: direct:production ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1 parent 4ee8c0f commit 72a0004

File tree

8 files changed

+56
-50
lines changed

8 files changed

+56
-50
lines changed

examples/async-client-hello-callback/src/bin/quic_async_client_hello_callback_server.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@ use moka::sync::Cache;
55
use rand::{distributions::WeightedIndex, prelude::*};
66
use s2n_quic::{
77
provider::tls::s2n_tls::{
8-
s2n_tls::{
9-
callbacks::{ConfigResolver, ConnectionFuture},
10-
config::Config,
11-
error::Error as S2nError,
12-
},
13-
ClientHelloCallback, Connection,
8+
callbacks::{ClientHelloCallback, ConfigResolver, ConnectionFuture},
9+
config::Config,
10+
connection::Connection,
11+
error::Error as S2nError,
1412
},
1513
Server,
1614
};

examples/resumption/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@ edition = "2021"
55

66
[dependencies]
77
s2n-quic = { version = "1", path = "../../quic/s2n-quic", features = ["provider-tls-s2n", "unstable_resumption"]}
8-
s2n-tls = { version = "=0.0.39", features = ["quic"] }
98
tokio = { version = "1", features = ["full"] }

examples/resumption/src/bin/server.rs

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
use s2n_quic::provider::tls::s2n_tls::{ConfigLoader, ConnectionContext, Server};
4+
use s2n_quic::provider::tls::s2n_tls::Server;
55
use std::{error::Error, time::SystemTime};
66

77
pub static CERT_PEM: &str = include_str!(concat!(
@@ -17,35 +17,18 @@ pub static KEY_PEM: &str = include_str!(concat!(
1717
pub static TICKET_KEY: [u8; 16] = [0; 16];
1818
pub static TICKET_KEY_NAME: &[u8] = "keyname".as_bytes();
1919

20-
struct ResumptionConfig;
21-
22-
impl ResumptionConfig {
23-
fn build() -> Result<s2n_tls::config::Config, s2n_tls::error::Error> {
24-
let mut config_builder = s2n_tls::config::Builder::new();
25-
config_builder
26-
.enable_session_tickets(true)?
27-
.add_session_ticket_key(TICKET_KEY_NAME, &TICKET_KEY, SystemTime::now())?
28-
.load_pem(CERT_PEM.as_bytes(), KEY_PEM.as_bytes())?
29-
.set_security_policy(&s2n_tls::security::DEFAULT_TLS13)?
30-
.enable_quic()?
31-
.set_application_protocol_preference([b"h3"])?;
32-
config_builder.build()
33-
}
34-
}
35-
36-
impl ConfigLoader for ResumptionConfig {
37-
fn load(&mut self, _cx: ConnectionContext) -> s2n_tls::config::Config {
38-
Self::build().expect("Config builder failed")
39-
}
40-
}
41-
4220
#[tokio::main]
4321
async fn main() -> Result<(), Box<dyn Error>> {
44-
let tls = Server::from_loader(ResumptionConfig);
22+
let mut tls = Server::builder().with_certificate(CERT_PEM, KEY_PEM)?;
23+
24+
tls.config_mut()
25+
.add_session_ticket_key(TICKET_KEY_NAME, &TICKET_KEY, SystemTime::now())?;
26+
4527
let mut server = s2n_quic::Server::builder()
46-
.with_tls(tls)?
28+
.with_tls(tls.build()?)?
4729
.with_io("127.0.0.1:4433")?
4830
.start()?;
31+
4932
while let Some(mut connection) = server.accept().await {
5033
// spawn a new task for the connection
5134
tokio::spawn(async move {

netbench/netbench-driver/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ netbench = { version = "0.1", path = "../netbench" }
1616
probe = "0.5"
1717
s2n-quic = { path = "../../quic/s2n-quic", features = ["provider-tls-s2n"] }
1818
s2n-quic-core = { path = "../../quic/s2n-quic-core", features = ["testing"] }
19-
s2n-tls = { version = "0.0.39" }
20-
s2n-tls-tokio = { version = "0.0.39" }
19+
s2n-tls = { version = "0.0.41" }
20+
s2n-tls-tokio = { version = "0.0.41" }
2121
structopt = "0.3"
2222
tokio = { version = "1", features = ["io-util", "net", "time", "rt-multi-thread"] }
2323
tokio-native-tls = "0.3"

quic/s2n-quic-tls/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ libc = "0.2"
2121
s2n-codec = { version = "=0.31.0", path = "../../common/s2n-codec", default-features = false }
2222
s2n-quic-core = { version = "=0.31.0", path = "../s2n-quic-core", default-features = false, features = ["alloc"] }
2323
s2n-quic-crypto = { version = "=0.31.0", path = "../s2n-quic-crypto", default-features = false }
24-
s2n-tls = { version = "=0.0.39", features = ["quic"] }
24+
s2n-tls = { version = "=0.0.41", features = ["quic"] }
2525

2626
[dev-dependencies]
2727
checkers = "0.6"

quic/s2n-quic-tls/src/client.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ impl Default for Builder {
8484
}
8585

8686
impl Builder {
87+
pub fn config_mut(&mut self) -> &mut s2n_tls::config::Builder {
88+
&mut self.config
89+
}
90+
8791
pub fn with_application_protocols<P: IntoIterator<Item = I>, I: AsRef<[u8]>>(
8892
mut self,
8993
protocols: P,

quic/s2n-quic-tls/src/lib.rs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
use s2n_quic_core::application::ServerName;
5-
use s2n_tls::config::Config;
65

76
/// Ensure memory is correctly managed in tests
87
#[cfg(test)]
@@ -23,26 +22,26 @@ pub struct ConnectionContext<'a> {
2322
///
2423
/// This trait can be implemented to override the default config loading for a QUIC endpoint
2524
pub trait ConfigLoader: 'static + Send {
26-
fn load(&mut self, cx: ConnectionContext) -> Config;
25+
fn load(&mut self, cx: ConnectionContext) -> config::Config;
2726
}
2827

29-
impl ConfigLoader for Config {
28+
impl ConfigLoader for config::Config {
3029
#[inline]
31-
fn load(&mut self, _cx: ConnectionContext) -> Config {
30+
fn load(&mut self, _cx: ConnectionContext) -> config::Config {
3231
self.clone()
3332
}
3433
}
3534

36-
impl<T: FnMut(ConnectionContext) -> Config + Send + 'static> ConfigLoader for T {
35+
impl<T: FnMut(ConnectionContext) -> config::Config + Send + 'static> ConfigLoader for T {
3736
#[inline]
38-
fn load(&mut self, cx: ConnectionContext) -> Config {
37+
fn load(&mut self, cx: ConnectionContext) -> config::Config {
3938
(self)(cx)
4039
}
4140
}
4241

4342
impl ConfigLoader for Box<dyn ConfigLoader> {
4443
#[inline]
45-
fn load(&mut self, cx: ConnectionContext) -> Config {
44+
fn load(&mut self, cx: ConnectionContext) -> config::Config {
4645
(**self).load(cx)
4746
}
4847
}
@@ -57,12 +56,8 @@ pub mod client;
5756
pub mod server;
5857

5958
pub use client::Client;
59+
pub use s2n_tls::*;
6060
pub use server::Server;
6161

62-
// Re-export the `ClientHelloHandler` and `Connection` to make it easier for users
63-
// to consume. This depends on experimental behavior in s2n-tls.
64-
#[cfg(any(test, all(s2n_quic_unstable, feature = "unstable_client_hello")))]
65-
pub use s2n_tls::{self, callbacks::ClientHelloCallback, connection::Connection};
66-
6762
#[cfg(test)]
6863
mod tests;

quic/s2n-quic-tls/src/tests.rs

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,27 @@ fn s2n_client_with_fixed_hostname_auth(host_name: &str) -> Result<client::Client
210210
.build()
211211
}
212212

213+
fn s2n_client_with_resumption() -> Result<client::Client, Error> {
214+
let mut builder = client::Builder::default().with_certificate(CERT_PEM)?;
215+
216+
struct TicketCallback;
217+
218+
impl s2n_tls::callbacks::SessionTicketCallback for TicketCallback {
219+
fn on_session_ticket(
220+
&self,
221+
_connection: &mut Connection,
222+
_session_ticket: &s2n_tls::callbacks::SessionTicket,
223+
) {
224+
}
225+
}
226+
227+
let cb = TicketCallback;
228+
builder.config_mut().set_session_ticket_callback(cb)?;
229+
builder.config_mut().enable_session_tickets(true)?;
230+
231+
builder.build()
232+
}
233+
213234
fn s2n_server() -> server::Server {
214235
server::Builder::default()
215236
.with_certificate(CERT_PEM, KEY_PEM)
@@ -320,11 +341,14 @@ fn s2n_client_s2n_server_test() {
320341
#[test]
321342
#[cfg_attr(miri, ignore)]
322343
fn s2n_client_s2n_server_resumption_test() {
323-
let mut client_endpoint = s2n_client();
344+
let mut client_endpoint = s2n_client_with_resumption().unwrap();
324345
let mut server_endpoint = s2n_server_with_resumption();
325346

326347
let pair = run_result(&mut server_endpoint, &mut client_endpoint, None).unwrap();
327-
assert!(!pair.client.context.application.rx.is_empty());
348+
assert!(
349+
!pair.client.context.application.rx.is_empty(),
350+
"expected session ticket message in RX"
351+
);
328352
}
329353

330354
#[test]
@@ -334,7 +358,10 @@ fn rustls_client_s2n_server_resumption_test() {
334358
let mut server_endpoint = s2n_server_with_resumption();
335359

336360
let pair = run_result(&mut server_endpoint, &mut client_endpoint, None).unwrap();
337-
assert!(!pair.client.context.application.rx.is_empty());
361+
assert!(
362+
!pair.client.context.application.rx.is_empty(),
363+
"expected session ticket message in RX"
364+
);
338365
}
339366

340367
#[test]

0 commit comments

Comments
 (0)