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

Update rustls and various dependencies #278

Merged
merged 1 commit into from
Jul 14, 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
64 changes: 32 additions & 32 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

64 changes: 32 additions & 32 deletions cli/tests/trap-test/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ hyper = { workspace = true }
itertools = { workspace = true }
lazy_static = "^1.4.0"
regex = "^1.3.9"
rustls = "^0.19.1"
rustls-native-certs = "^0.5.0"
rustls = "^0.21.1"
rustls-native-certs = "^0.6.3"
semver = "^0.10.0"
serde = "^1.0.145"
serde_derive = "^1.0.114"
serde_json = { workspace = true }
thiserror = "^1.0.37"
tokio = { workspace = true }
tokio-rustls = "^0.22.0"
tokio-rustls = "^0.24.1"
toml = "^0.5.9"
tracing = { workspace = true }
tracing-futures = { workspace = true }
Expand All @@ -54,7 +54,6 @@ wasi-common = { workspace = true }
wasmtime = { workspace = true }
wasmtime-wasi = "10.0.0"
wasmtime-wasi-nn = "10.0.0"
webpki = "^0.21.0"
wiggle = "10.0.0"

[dev-dependencies]
Expand Down
28 changes: 16 additions & 12 deletions lib/src/upstream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use crate::{
use futures::Future;
use http::{uri, HeaderValue};
use hyper::{client::HttpConnector, header, Client, HeaderMap, Request, Response, Uri};
use rustls::client::ServerName;
use std::{
io,
pin::Pin,
Expand All @@ -22,7 +23,6 @@ use tokio::{
};
use tokio_rustls::{client::TlsStream, TlsConnector};
use tracing::warn;
use webpki::DNSNameRef;

static GZIP_VALUES: [HeaderValue; 2] = [
HeaderValue::from_static("gzip"),
Expand All @@ -41,19 +41,23 @@ pub struct TlsConfig {
}

fn setup_rustls(with_sni: bool) -> Result<rustls::ClientConfig, Error> {
let mut config = rustls::ClientConfig::new();
config.root_store = match rustls_native_certs::load_native_certs() {
Ok(store) => store,
Err((Some(store), err)) => {
warn!(%err, "some certificates could not be loaded");
store
let mut roots = rustls::RootCertStore::empty();
match rustls_native_certs::load_native_certs() {
Ok(certs) => {
for cert in certs {
roots.add(&rustls::Certificate(cert.0)).unwrap();
}
}
Err((None, err)) => return Err(Error::BadCerts(err)),
};
if config.root_store.is_empty() {
Err(err) => return Err(Error::BadCerts(err)),
}
if roots.is_empty() {
warn!("no CA certificates available");
}
config.alpn_protocols.clear();

let mut config = rustls::ClientConfig::builder()
.with_safe_defaults()
.with_root_certificates(roots)
.with_no_client_auth();
config.enable_sni = with_sni;
Ok(config)
}
Expand Down Expand Up @@ -134,7 +138,7 @@ impl hyper::service::Service<Uri> for BackendConnector {
.as_deref()
.or_else(|| backend.uri.host())
.unwrap_or_default();
let dnsname = DNSNameRef::try_from_ascii_str(cert_host).map_err(Box::new)?;
let dnsname = ServerName::try_from(cert_host).map_err(Box::new)?;

let tls = connector.connect(dnsname, tcp).await.map_err(Box::new)?;
Ok(Connection::Https(Box::new(tls)))
Expand Down
Loading