Skip to content

Commit e49f673

Browse files
Track the latest changes from upstream rustls (#21)
1 parent 94bfa8e commit e49f673

File tree

7 files changed

+20
-30
lines changed

7 files changed

+20
-30
lines changed

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ exclude = ["/.github", "/examples", "/scripts"]
1414

1515
[dependencies]
1616
tokio = "1.0"
17-
rustls = { version = "=0.22.0-alpha.2", default-features = false }
17+
rustls = { version = "=0.22.0-alpha.3", default-features = false }
1818

1919
[features]
20-
default = ["logging", "tls12"]
21-
dangerous_configuration = ["rustls/dangerous_configuration"]
20+
default = ["logging", "tls12", "ring"]
2221
early-data = []
2322
logging = ["rustls/logging"]
23+
ring = ["rustls/ring"]
2424
secret_extraction = ["rustls/secret_extraction"]
2525
tls12 = ["rustls/tls12"]
2626

@@ -31,4 +31,4 @@ futures-util = "0.3.1"
3131
lazy_static = "1.1"
3232
webpki-roots = "=0.26.0-alpha.1"
3333
rustls-pemfile = "=2.0.0-alpha.1"
34-
webpki = { package = "rustls-webpki", version = "=0.102.0-alpha.2", features = ["alloc", "std"] }
34+
webpki = { package = "rustls-webpki", version = "=0.102.0-alpha.3", features = ["alloc", "std"] }

examples/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ async fn main() -> io::Result<()> {
4848
root_cert_store.add(cert?).unwrap();
4949
}
5050
} else {
51-
root_cert_store.add_trust_anchors(webpki_roots::TLS_SERVER_ROOTS.iter().cloned());
51+
root_cert_store.extend(webpki_roots::TLS_SERVER_ROOTS.iter().cloned());
5252
}
5353

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

src/lib.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ use std::sync::Arc;
4747
use std::task::{Context, Poll};
4848

4949
pub use rustls;
50-
use rustls::crypto::ring::Ring;
5150
use rustls::{ClientConfig, ClientConnection, CommonState, ServerConfig, ServerConnection};
5251
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
5352

@@ -68,19 +67,19 @@ pub mod server;
6867
/// A wrapper around a `rustls::ClientConfig`, providing an async `connect` method.
6968
#[derive(Clone)]
7069
pub struct TlsConnector {
71-
inner: Arc<ClientConfig<Ring>>,
70+
inner: Arc<ClientConfig>,
7271
#[cfg(feature = "early-data")]
7372
early_data: bool,
7473
}
7574

7675
/// A wrapper around a `rustls::ServerConfig`, providing an async `accept` method.
7776
#[derive(Clone)]
7877
pub struct TlsAcceptor {
79-
inner: Arc<ServerConfig<Ring>>,
78+
inner: Arc<ServerConfig>,
8079
}
8180

82-
impl From<Arc<ClientConfig<Ring>>> for TlsConnector {
83-
fn from(inner: Arc<ClientConfig<Ring>>) -> TlsConnector {
81+
impl From<Arc<ClientConfig>> for TlsConnector {
82+
fn from(inner: Arc<ClientConfig>) -> TlsConnector {
8483
TlsConnector {
8584
inner,
8685
#[cfg(feature = "early-data")]
@@ -89,8 +88,8 @@ impl From<Arc<ClientConfig<Ring>>> for TlsConnector {
8988
}
9089
}
9190

92-
impl From<Arc<ServerConfig<Ring>>> for TlsAcceptor {
93-
fn from(inner: Arc<ServerConfig<Ring>>) -> TlsAcceptor {
91+
impl From<Arc<ServerConfig>> for TlsAcceptor {
92+
fn from(inner: Arc<ServerConfig>) -> TlsAcceptor {
9493
TlsAcceptor { inner }
9594
}
9695
}
@@ -211,10 +210,9 @@ where
211210
/// # Example
212211
///
213212
/// ```no_run
214-
/// # use rustls::crypto::ring::Ring;
215213
/// # fn choose_server_config(
216214
/// # _: rustls::server::ClientHello,
217-
/// # ) -> std::sync::Arc<rustls::ServerConfig<Ring>> {
215+
/// # ) -> std::sync::Arc<rustls::ServerConfig> {
218216
/// # unimplemented!();
219217
/// # }
220218
/// # #[allow(unused_variables)]
@@ -306,11 +304,11 @@ where
306304
self.accepted.client_hello()
307305
}
308306

309-
pub fn into_stream(self, config: Arc<ServerConfig<Ring>>) -> Accept<IO> {
307+
pub fn into_stream(self, config: Arc<ServerConfig>) -> Accept<IO> {
310308
self.into_stream_with(config, |_| ())
311309
}
312310

313-
pub fn into_stream_with<F>(self, config: Arc<ServerConfig<Ring>>, f: F) -> Accept<IO>
311+
pub fn into_stream_with<F>(self, config: Arc<ServerConfig>, f: F) -> Accept<IO>
314312
where
315313
F: FnOnce(&mut ServerConnection),
316314
{

tests/badssl.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use std::io;
22
use std::net::ToSocketAddrs;
33
use std::sync::Arc;
44

5-
use rustls::crypto::ring::Ring;
65
use tokio::io::{AsyncReadExt, AsyncWriteExt};
76
use tokio::net::TcpStream;
87
use tokio_rustls::{
@@ -12,7 +11,7 @@ use tokio_rustls::{
1211
};
1312

1413
async fn get(
15-
config: Arc<ClientConfig<Ring>>,
14+
config: Arc<ClientConfig>,
1615
domain: &str,
1716
port: u16,
1817
) -> io::Result<(TlsStream<TcpStream>, String)> {
@@ -35,7 +34,7 @@ async fn get(
3534
#[tokio::test]
3635
async fn test_tls12() -> io::Result<()> {
3736
let mut root_store = rustls::RootCertStore::empty();
38-
root_store.add_trust_anchors(webpki_roots::TLS_SERVER_ROOTS.iter().cloned());
37+
root_store.extend(webpki_roots::TLS_SERVER_ROOTS.iter().cloned());
3938
let config = rustls::ClientConfig::builder()
4039
.with_safe_default_cipher_suites()
4140
.with_safe_default_kx_groups()
@@ -67,7 +66,7 @@ fn test_tls13() {
6766
#[tokio::test]
6867
async fn test_modern() -> io::Result<()> {
6968
let mut root_store = rustls::RootCertStore::empty();
70-
root_store.add_trust_anchors(webpki_roots::TLS_SERVER_ROOTS.iter().cloned());
69+
root_store.extend(webpki_roots::TLS_SERVER_ROOTS.iter().cloned());
7170
let config = rustls::ClientConfig::builder()
7271
.with_safe_defaults()
7372
.with_root_certificates(root_store)

tests/early-data.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use std::thread;
1010
use std::time::Duration;
1111

1212
use futures_util::{future, future::Future, ready};
13-
use rustls::crypto::ring::Ring;
1413
use rustls::{self, ClientConfig, RootCertStore};
1514
use tokio::io::{split, AsyncRead, AsyncWriteExt, ReadBuf};
1615
use tokio::net::TcpStream;
@@ -39,7 +38,7 @@ impl<T: AsyncRead + Unpin> Future for Read1<T> {
3938
}
4039

4140
async fn send(
42-
config: Arc<ClientConfig<Ring>>,
41+
config: Arc<ClientConfig>,
4342
addr: SocketAddr,
4443
data: &[u8],
4544
) -> io::Result<TlsStream<TcpStream>> {

tests/test.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use std::{io, thread};
77

88
use futures_util::future::TryFutureExt;
99
use lazy_static::lazy_static;
10-
use rustls::crypto::ring::Ring;
1110
use rustls::ClientConfig;
1211
use rustls_pemfile::{certs, rsa_private_keys};
1312
use tokio::io::{copy, split, AsyncReadExt, AsyncWriteExt};
@@ -84,11 +83,7 @@ fn start_server() -> &'static (SocketAddr, &'static str, &'static [u8]) {
8483
&TEST_SERVER
8584
}
8685

87-
async fn start_client(
88-
addr: SocketAddr,
89-
domain: &str,
90-
config: Arc<ClientConfig<Ring>>,
91-
) -> io::Result<()> {
86+
async fn start_client(addr: SocketAddr, domain: &str, config: Arc<ClientConfig>) -> io::Result<()> {
9287
const FILE: &[u8] = include_bytes!("../README.md");
9388

9489
let domain = rustls::ServerName::try_from(domain).unwrap();

tests/utils.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@ mod utils {
22
use std::io::{BufReader, Cursor};
33
use std::sync::Arc;
44

5-
use rustls::crypto::ring::Ring;
65
use rustls::{ClientConfig, RootCertStore, ServerConfig};
76
use rustls_pemfile::{certs, rsa_private_keys};
87

98
#[allow(dead_code)]
10-
pub fn make_configs() -> (Arc<ServerConfig<Ring>>, Arc<ClientConfig<Ring>>) {
9+
pub fn make_configs() -> (Arc<ServerConfig>, Arc<ClientConfig>) {
1110
const CERT: &str = include_str!("end.cert");
1211
const CHAIN: &str = include_str!("end.chain");
1312
const RSA: &str = include_str!("end.rsa");

0 commit comments

Comments
 (0)