Skip to content

Commit 092f3b3

Browse files
tottotoseanmonstar
authored andcommitted
examples: update to rustls 0.23
1 parent be12983 commit 092f3b3

File tree

2 files changed

+4
-13
lines changed

2 files changed

+4
-13
lines changed

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ serde_json = "1.0.0"
6666
# Examples
6767
tokio = { version = "1", features = ["rt-multi-thread", "macros", "sync", "net"] }
6868
env_logger = { version = "0.10", default-features = false }
69-
tokio-rustls = "0.24"
70-
webpki-roots = "0.25"
69+
tokio-rustls = "0.26"
70+
webpki-roots = "0.26"
7171

7272
[package.metadata.docs.rs]
7373
features = ["stream"]

examples/akamai.rs

+2-11
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use http::{Method, Request};
33
use tokio::net::TcpStream;
44
use tokio_rustls::TlsConnector;
55

6-
use tokio_rustls::rustls::{OwnedTrustAnchor, RootCertStore, ServerName};
6+
use tokio_rustls::rustls::{pki_types::ServerName, RootCertStore};
77

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

1717
let tls_client_config = std::sync::Arc::new({
18-
let mut root_store = RootCertStore::empty();
19-
root_store.add_trust_anchors(webpki_roots::TLS_SERVER_ROOTS.iter().map(|ta| {
20-
OwnedTrustAnchor::from_subject_spki_name_constraints(
21-
ta.subject,
22-
ta.spki,
23-
ta.name_constraints,
24-
)
25-
}));
26-
18+
let root_store = RootCertStore::from_iter(webpki_roots::TLS_SERVER_ROOTS.iter().cloned());
2719
let mut c = tokio_rustls::rustls::ClientConfig::builder()
28-
.with_safe_defaults()
2920
.with_root_certificates(root_store)
3021
.with_no_client_auth();
3122
c.alpn_protocols.push(ALPN_H2.as_bytes().to_owned());

0 commit comments

Comments
 (0)