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

build(deps): update s2n-tls to 0.0.21 #1587

Merged
merged 1 commit into from
Dec 9, 2022
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
4 changes: 2 additions & 2 deletions netbench/netbench-driver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ netbench = { version = "0.1", path = "../netbench" }
probe = "0.3"
s2n-quic = { path = "../../quic/s2n-quic", features = ["provider-tls-s2n"] }
s2n-quic-core = { path = "../../quic/s2n-quic-core", features = ["testing"] }
s2n-tls = { version = "=0.0.19" }
s2n-tls-tokio = { version = "=0.0.19" }
s2n-tls = { version = "=0.0.21" }
s2n-tls-tokio = { version = "=0.0.21" }
structopt = "0.3"
tokio = { version = "1", features = ["io-util", "net", "time"] }
tokio-native-tls = "0.3"
Expand Down
4 changes: 2 additions & 2 deletions quic/s2n-quic-tls/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ libc = "0.2"
s2n-codec = { version = "=0.2.0", path = "../../common/s2n-codec", default-features = false }
s2n-quic-core = { version = "=0.14.0", path = "../s2n-quic-core", default-features = false }
s2n-quic-crypto = { version = "=0.14.0", path = "../s2n-quic-crypto", default-features = false }
s2n-tls = { version = "=0.0.19", features = ["quic"] }
s2n-tls = { version = "=0.0.21", features = ["quic"] }

[target.'cfg(all(s2n_quic_unstable, s2n_quic_enable_pq_tls))'.dependencies]
s2n-tls = { version = "=0.0.19", features = ["quic", "pq"] }
s2n-tls = { version = "=0.0.21", features = ["quic", "pq"] }

[dev-dependencies]
checkers = "0.6"
Expand Down
12 changes: 3 additions & 9 deletions quic/s2n-quic-tls/src/certificate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,13 @@ macro_rules! cert_type {
fn $method(self) -> Result<$name, Error> {
match self.extension() {
Some(ext) if ext == "der" => {
let pem = std::fs::read(self).map_err(map_io_error)?;
let pem = std::fs::read(self).map_err(|err| Error::io_error(err))?;
pem.$method()
}
// assume it's in pem format
_ => {
let pem = std::fs::read_to_string(self).map_err(map_io_error)?;
let pem =
std::fs::read_to_string(self).map_err(|err| Error::io_error(err))?;
pem.$method()
}
}
Expand All @@ -105,10 +106,3 @@ macro_rules! cert_type {

cert_type!(PrivateKey, IntoPrivateKey, into_private_key);
cert_type!(Certificate, IntoCertificate, into_certificate);

/// Converts an io::Error into an s2n-tls Error
fn map_io_error(err: std::io::Error) -> Error {
let errno = err.raw_os_error().unwrap_or(1);
errno::set_errno(errno::Errno(errno));
Error::new(s2n_tls::ffi::s2n_status_code::FAILURE).unwrap_err()
}
28 changes: 25 additions & 3 deletions quic/s2n-quic-tls/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ use s2n_quic_core::{
};
#[cfg(any(test, all(s2n_quic_unstable, feature = "unstable_client_hello")))]
use s2n_tls::{callbacks::ClientHelloCallback, connection::Connection};
use s2n_tls::{callbacks::VerifyHostNameCallback, error::Error};
use s2n_tls::{
callbacks::{ConnectionFuture, VerifyHostNameCallback},
error::Error,
};
use std::sync::Arc;

pub struct MyClientHelloHandler {
Expand All @@ -35,10 +38,29 @@ impl MyClientHelloHandler {

#[cfg(any(test, all(s2n_quic_unstable, feature = "unstable_client_hello")))]
impl ClientHelloCallback for MyClientHelloHandler {
fn poll_client_hello(
fn on_client_hello(
&self,
_connection: &mut Connection,
) -> core::task::Poll<Result<(), Error>> {
) -> Result<Option<std::pin::Pin<Box<dyn s2n_tls::callbacks::ConnectionFuture>>>, Error> {
let fut = MyConnectionFuture {
done: self.done.clone(),
wait_counter: self.wait_counter.clone(),
};
Ok(Some(Box::pin(fut)))
}
}

struct MyConnectionFuture {
done: Arc<AtomicBool>,
wait_counter: Arc<AtomicU8>,
}

impl ConnectionFuture for MyConnectionFuture {
fn poll(
self: std::pin::Pin<&mut Self>,
_connection: &mut Connection,
_ctx: &mut core::task::Context,
) -> Poll<Result<(), Error>> {
if self.wait_counter.fetch_sub(1, Ordering::SeqCst) == 0 {
self.done.store(true, Ordering::SeqCst);
return Poll::Ready(Ok(()));
Expand Down