diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 5dbef16..cabb3fb 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -5,6 +5,8 @@ on: branches: - master pull_request: {} + schedule: + - cron: "33 4 * * 5" jobs: check: diff --git a/tokio-rustls/src/common/test_stream.rs b/tokio-rustls/src/common/test_stream.rs index c949b7b..5431b7c 100644 --- a/tokio-rustls/src/common/test_stream.rs +++ b/tokio-rustls/src/common/test_stream.rs @@ -129,8 +129,6 @@ async fn stream_good() -> io::Result<()> { io::copy(&mut Cursor::new(FILE), &mut server.writer())?; server.send_close_notify(); - let mut server = Connection::from(server); - { let mut good = Good(&mut server); let mut stream = Stream::new(&mut good, &mut client); diff --git a/tokio-rustls/src/lib.rs b/tokio-rustls/src/lib.rs index 6c3960a..27b26e1 100644 --- a/tokio-rustls/src/lib.rs +++ b/tokio-rustls/src/lib.rs @@ -401,11 +401,11 @@ impl TlsStream { match self { Client(io) => { let (io, session) = io.get_ref(); - (io, &*session) + (io, session) } Server(io) => { let (io, session) = io.get_ref(); - (io, &*session) + (io, session) } } } diff --git a/tokio-rustls/tests/test.rs b/tokio-rustls/tests/test.rs index 34ff164..87e77d1 100644 --- a/tokio-rustls/tests/test.rs +++ b/tokio-rustls/tests/test.rs @@ -111,19 +111,16 @@ async fn pass() -> io::Result<()> { tokio::time::sleep(Duration::from_secs(1)).await; let chain = certs(&mut std::io::Cursor::new(*chain)).unwrap(); - let trust_anchors = chain - .iter() - .map(|cert| { - let ta = webpki::TrustAnchor::try_from_cert_der(&cert[..]).unwrap(); - OwnedTrustAnchor::from_subject_spki_name_constraints( - ta.subject, - ta.spki, - ta.name_constraints, - ) - }) - .collect::>(); let mut root_store = rustls::RootCertStore::empty(); - root_store.add_server_trust_anchors(trust_anchors.into_iter()); + root_store.add_server_trust_anchors(chain.iter().map(|cert| { + let ta = webpki::TrustAnchor::try_from_cert_der(&cert[..]).unwrap(); + OwnedTrustAnchor::from_subject_spki_name_constraints( + ta.subject, + ta.spki, + ta.name_constraints, + ) + })); + let config = rustls::ClientConfig::builder() .with_safe_defaults() .with_root_certificates(root_store) @@ -140,19 +137,16 @@ async fn fail() -> io::Result<()> { let (addr, domain, chain) = start_server(); let chain = certs(&mut std::io::Cursor::new(*chain)).unwrap(); - let trust_anchors = chain - .iter() - .map(|cert| { - let ta = webpki::TrustAnchor::try_from_cert_der(&cert[..]).unwrap(); - OwnedTrustAnchor::from_subject_spki_name_constraints( - ta.subject, - ta.spki, - ta.name_constraints, - ) - }) - .collect::>(); let mut root_store = rustls::RootCertStore::empty(); - root_store.add_server_trust_anchors(trust_anchors.into_iter()); + root_store.add_server_trust_anchors(chain.iter().map(|cert| { + let ta = webpki::TrustAnchor::try_from_cert_der(&cert[..]).unwrap(); + OwnedTrustAnchor::from_subject_spki_name_constraints( + ta.subject, + ta.spki, + ta.name_constraints, + ) + })); + let config = rustls::ClientConfig::builder() .with_safe_defaults() .with_root_certificates(root_store) @@ -190,7 +184,7 @@ async fn test_lazy_config_acceptor() -> io::Result<()> { assert_eq!( ch.alpn() .map(|protos| protos.collect::>()) - .unwrap_or(Vec::new()), + .unwrap_or_default(), Vec::<&[u8]>::new() ); diff --git a/tokio-rustls/tests/utils.rs b/tokio-rustls/tests/utils.rs index c0f7ed0..161fa91 100644 --- a/tokio-rustls/tests/utils.rs +++ b/tokio-rustls/tests/utils.rs @@ -27,18 +27,15 @@ mod utils { let mut client_root_cert_store = RootCertStore::empty(); let mut chain = BufReader::new(Cursor::new(CHAIN)); let certs = certs(&mut chain).unwrap(); - let trust_anchors = certs - .iter() - .map(|cert| { - let ta = webpki::TrustAnchor::try_from_cert_der(&cert[..]).unwrap(); - OwnedTrustAnchor::from_subject_spki_name_constraints( - ta.subject, - ta.spki, - ta.name_constraints, - ) - }) - .collect::>(); - client_root_cert_store.add_server_trust_anchors(trust_anchors.into_iter()); + client_root_cert_store.add_server_trust_anchors(certs.iter().map(|cert| { + let ta = webpki::TrustAnchor::try_from_cert_der(&cert[..]).unwrap(); + OwnedTrustAnchor::from_subject_spki_name_constraints( + ta.subject, + ta.spki, + ta.name_constraints, + ) + })); + let cconfig = ClientConfig::builder() .with_safe_defaults() .with_root_certificates(client_root_cert_store)