Skip to content

Commit a4c184a

Browse files
committed
Avoid deprecated rustls API
1 parent b5b7c0e commit a4c184a

File tree

7 files changed

+21
-22
lines changed

7 files changed

+21
-22
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ rust-version = "1.60"
1313

1414
[dependencies]
1515
tokio = "1.0"
16-
rustls = { version = "0.21.0", default-features = false }
16+
rustls = { version = "0.21.6", default-features = false }
1717

1818
[features]
1919
default = ["logging", "tls12"]

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# tokio-rustls
2+
23
[![github actions](https://github.com/rustls/tokio-rustls/workflows/CI/badge.svg)](https://github.com/rustls/tokio-rustls/actions)
34
[![crates](https://img.shields.io/crates/v/tokio-rustls.svg)](https://crates.io/crates/tokio-rustls)
45
[![license](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/rustls/tokio-rustls/blob/main/LICENSE-MIT)
@@ -19,7 +20,7 @@ use tokio_rustls::TlsConnector;
1920
// ...
2021

2122
let mut root_cert_store = RootCertStore::empty();
22-
root_cert_store.add_server_trust_anchors(webpki_roots::TLS_SERVER_ROOTS.0.iter().map(|ta| {
23+
root_cert_store.add_trust_anchors(webpki_roots::TLS_SERVER_ROOTS.0.iter().map(|ta| {
2324
OwnedTrustAnchor::from_subject_spki_name_constraints(
2425
ta.subject,
2526
ta.spki,
@@ -61,10 +62,10 @@ cargo run -- 127.0.0.1:8000 --cert mycert.der --key mykey.der
6162

6263
This project is licensed under either of
6364

64-
* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
65-
https://www.apache.org/licenses/LICENSE-2.0)
66-
* MIT license ([LICENSE-MIT](LICENSE-MIT) or
67-
https://opensource.org/licenses/MIT)
65+
- Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
66+
https://www.apache.org/licenses/LICENSE-2.0)
67+
- MIT license ([LICENSE-MIT](LICENSE-MIT) or
68+
https://opensource.org/licenses/MIT)
6869

6970
at your option.
7071

examples/client.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,15 @@ async fn main() -> io::Result<()> {
5454
ta.name_constraints,
5555
)
5656
});
57-
root_cert_store.add_server_trust_anchors(trust_anchors);
57+
root_cert_store.add_trust_anchors(trust_anchors);
5858
} else {
59-
root_cert_store.add_server_trust_anchors(webpki_roots::TLS_SERVER_ROOTS.iter().map(
60-
|ta| {
61-
OwnedTrustAnchor::from_subject_spki_name_constraints(
62-
ta.subject,
63-
ta.spki,
64-
ta.name_constraints,
65-
)
66-
},
67-
));
59+
root_cert_store.add_trust_anchors(webpki_roots::TLS_SERVER_ROOTS.iter().map(|ta| {
60+
OwnedTrustAnchor::from_subject_spki_name_constraints(
61+
ta.subject,
62+
ta.spki,
63+
ta.name_constraints,
64+
)
65+
}));
6866
}
6967

7068
let config = rustls::ClientConfig::builder()

tests/badssl.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ async fn get(
3434
#[tokio::test]
3535
async fn test_tls12() -> io::Result<()> {
3636
let mut root_store = rustls::RootCertStore::empty();
37-
root_store.add_server_trust_anchors(webpki_roots::TLS_SERVER_ROOTS.iter().map(|ta| {
37+
root_store.add_trust_anchors(webpki_roots::TLS_SERVER_ROOTS.iter().map(|ta| {
3838
OwnedTrustAnchor::from_subject_spki_name_constraints(
3939
ta.subject,
4040
ta.spki,
@@ -72,7 +72,7 @@ fn test_tls13() {
7272
#[tokio::test]
7373
async fn test_modern() -> io::Result<()> {
7474
let mut root_store = rustls::RootCertStore::empty();
75-
root_store.add_server_trust_anchors(webpki_roots::TLS_SERVER_ROOTS.iter().map(|ta| {
75+
root_store.add_trust_anchors(webpki_roots::TLS_SERVER_ROOTS.iter().map(|ta| {
7676
OwnedTrustAnchor::from_subject_spki_name_constraints(
7777
ta.subject,
7878
ta.spki,

tests/early-data.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ async fn test_0rtt() -> io::Result<()> {
142142
)
143143
});
144144
let mut root_store = RootCertStore::empty();
145-
root_store.add_server_trust_anchors(trust_anchors);
145+
root_store.add_trust_anchors(trust_anchors);
146146
let mut config = rustls::ClientConfig::builder()
147147
.with_safe_default_cipher_suites()
148148
.with_safe_default_kx_groups()

tests/test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ async fn pass() -> io::Result<()> {
113113

114114
let chain = certs(&mut std::io::Cursor::new(*chain)).unwrap();
115115
let mut root_store = rustls::RootCertStore::empty();
116-
root_store.add_server_trust_anchors(chain.iter().map(|cert| {
116+
root_store.add_trust_anchors(chain.iter().map(|cert| {
117117
let ta = webpki::TrustAnchor::try_from_cert_der(&cert[..]).unwrap();
118118
OwnedTrustAnchor::from_subject_spki_name_constraints(
119119
ta.subject,
@@ -139,7 +139,7 @@ async fn fail() -> io::Result<()> {
139139

140140
let chain = certs(&mut std::io::Cursor::new(*chain)).unwrap();
141141
let mut root_store = rustls::RootCertStore::empty();
142-
root_store.add_server_trust_anchors(chain.iter().map(|cert| {
142+
root_store.add_trust_anchors(chain.iter().map(|cert| {
143143
let ta = webpki::TrustAnchor::try_from_cert_der(&cert[..]).unwrap();
144144
OwnedTrustAnchor::from_subject_spki_name_constraints(
145145
ta.subject,

tests/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ mod utils {
2727
let mut client_root_cert_store = RootCertStore::empty();
2828
let mut chain = BufReader::new(Cursor::new(CHAIN));
2929
let certs = certs(&mut chain).unwrap();
30-
client_root_cert_store.add_server_trust_anchors(certs.iter().map(|cert| {
30+
client_root_cert_store.add_trust_anchors(certs.iter().map(|cert| {
3131
let ta = webpki::TrustAnchor::try_from_cert_der(&cert[..]).unwrap();
3232
OwnedTrustAnchor::from_subject_spki_name_constraints(
3333
ta.subject,

0 commit comments

Comments
 (0)