Skip to content

Commit

Permalink
anchors: deprecate add_server_trust_anchors.
Browse files Browse the repository at this point in the history
The `RootCertStore` type is used for both client and server trust
anchors. This commit deprecates the inappropriately named
`add_server_trust_anchors` fn and adds a new `add_trust_anchors` fn to
use in its place.
  • Loading branch information
cpu committed Aug 2, 2023
1 parent 4b8be56 commit 2ac3cec
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion examples/src/bin/limitedclient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use rustls::OwnedTrustAnchor;

fn main() {
let mut root_store = rustls::RootCertStore::empty();
root_store.add_server_trust_anchors(
root_store.add_trust_anchors(
webpki_roots::TLS_SERVER_ROOTS
.0
.iter()
Expand Down
2 changes: 1 addition & 1 deletion examples/src/bin/simple_0rtt_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ fn main() {
env_logger::init();

let mut root_store = RootCertStore::empty();
root_store.add_server_trust_anchors(
root_store.add_trust_anchors(
webpki_roots::TLS_SERVER_ROOTS
.0
.iter()
Expand Down
2 changes: 1 addition & 1 deletion examples/src/bin/simpleclient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use rustls::{OwnedTrustAnchor, RootCertStore};

fn main() {
let mut root_store = RootCertStore::empty();
root_store.add_server_trust_anchors(
root_store.add_trust_anchors(
webpki_roots::TLS_SERVER_ROOTS
.0
.iter()
Expand Down
2 changes: 1 addition & 1 deletion examples/src/bin/tlsclient-mio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ fn make_config(args: &Args) -> Arc<rustls::ClientConfig> {
let mut reader = BufReader::new(certfile);
root_store.add_parsable_certificates(&rustls_pemfile::certs(&mut reader).unwrap());
} else {
root_store.add_server_trust_anchors(
root_store.add_trust_anchors(
webpki_roots::TLS_SERVER_ROOTS
.0
.iter()
Expand Down
9 changes: 8 additions & 1 deletion rustls/src/anchors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,18 @@ impl RootCertStore {

/// Adds all the given TrustAnchors `anchors`. This does not
/// fail.
pub fn add_trust_anchors(&mut self, trust_anchors: impl Iterator<Item = OwnedTrustAnchor>) {
self.roots.extend(trust_anchors);
}

/// Adds all the given TrustAnchors `anchors`. This does not
/// fail.
#[deprecated(since = "0.21.6", note = "Please use `add_trust_anchors` instead")]
pub fn add_server_trust_anchors(
&mut self,
trust_anchors: impl Iterator<Item = OwnedTrustAnchor>,
) {
self.roots.extend(trust_anchors);
self.add_trust_anchors(trust_anchors);
}

/// Parse the given DER-encoded certificates and add all that can be parsed
Expand Down
4 changes: 2 additions & 2 deletions rustls/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
//!
//! ```rust,no_run
//! let mut root_store = rustls::RootCertStore::empty();
//! root_store.add_server_trust_anchors(
//! root_store.add_trust_anchors(
//! webpki_roots::TLS_SERVER_ROOTS
//! .0
//! .iter()
Expand Down Expand Up @@ -138,7 +138,7 @@
//! # use webpki;
//! # use std::sync::Arc;
//! # let mut root_store = rustls::RootCertStore::empty();
//! # root_store.add_server_trust_anchors(
//! # root_store.add_trust_anchors(
//! # webpki_roots::TLS_SERVER_ROOTS
//! # .0
//! # .iter()
Expand Down
2 changes: 1 addition & 1 deletion rustls/src/verifybench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ struct Context {
impl Context {
fn new(name: &'static str, domain: &'static str, certs: &[&'static [u8]]) -> Self {
let mut roots = anchors::RootCertStore::empty();
roots.add_server_trust_anchors(
roots.add_trust_anchors(
webpki_roots::TLS_SERVER_ROOTS
.0
.iter()
Expand Down

0 comments on commit 2ac3cec

Please sign in to comment.