Skip to content

Commit

Permalink
examples: update to rustls 0.23
Browse files Browse the repository at this point in the history
  • Loading branch information
tottoto committed May 4, 2024
1 parent be12983 commit d1fa690
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ serde_json = "1.0.0"
# Examples
tokio = { version = "1", features = ["rt-multi-thread", "macros", "sync", "net"] }
env_logger = { version = "0.10", default-features = false }
tokio-rustls = "0.24"
webpki-roots = "0.25"
tokio-rustls = "0.26"
webpki-roots = "0.26"

[package.metadata.docs.rs]
features = ["stream"]
Expand Down
13 changes: 2 additions & 11 deletions examples/akamai.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use http::{Method, Request};
use tokio::net::TcpStream;
use tokio_rustls::TlsConnector;

use tokio_rustls::rustls::{OwnedTrustAnchor, RootCertStore, ServerName};
use tokio_rustls::rustls::{pki_types::ServerName, RootCertStore};

use std::error::Error;
use std::net::ToSocketAddrs;
Expand All @@ -15,17 +15,8 @@ pub async fn main() -> Result<(), Box<dyn Error>> {
let _ = env_logger::try_init();

let tls_client_config = std::sync::Arc::new({
let mut root_store = RootCertStore::empty();
root_store.add_trust_anchors(webpki_roots::TLS_SERVER_ROOTS.iter().map(|ta| {
OwnedTrustAnchor::from_subject_spki_name_constraints(
ta.subject,
ta.spki,
ta.name_constraints,
)
}));

let root_store = RootCertStore::from_iter(webpki_roots::TLS_SERVER_ROOTS.iter().cloned());
let mut c = tokio_rustls::rustls::ClientConfig::builder()
.with_safe_defaults()
.with_root_certificates(root_store)
.with_no_client_auth();
c.alpn_protocols.push(ALPN_H2.as_bytes().to_owned());
Expand Down

0 comments on commit d1fa690

Please sign in to comment.