Clippy fixes (#118)

This commit is contained in:
Dirkjan Ochtman 2022-10-11 16:12:04 +02:00 committed by GitHub
parent 87ecfe7c01
commit c033514814
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 32 additions and 41 deletions

View File

@ -5,6 +5,8 @@ on:
branches: branches:
- master - master
pull_request: {} pull_request: {}
schedule:
- cron: "33 4 * * 5"
jobs: jobs:
check: check:

View File

@ -129,8 +129,6 @@ async fn stream_good() -> io::Result<()> {
io::copy(&mut Cursor::new(FILE), &mut server.writer())?; io::copy(&mut Cursor::new(FILE), &mut server.writer())?;
server.send_close_notify(); server.send_close_notify();
let mut server = Connection::from(server);
{ {
let mut good = Good(&mut server); let mut good = Good(&mut server);
let mut stream = Stream::new(&mut good, &mut client); let mut stream = Stream::new(&mut good, &mut client);

View File

@ -401,11 +401,11 @@ impl<T> TlsStream<T> {
match self { match self {
Client(io) => { Client(io) => {
let (io, session) = io.get_ref(); let (io, session) = io.get_ref();
(io, &*session) (io, session)
} }
Server(io) => { Server(io) => {
let (io, session) = io.get_ref(); let (io, session) = io.get_ref();
(io, &*session) (io, session)
} }
} }
} }

View File

@ -111,19 +111,16 @@ async fn pass() -> io::Result<()> {
tokio::time::sleep(Duration::from_secs(1)).await; tokio::time::sleep(Duration::from_secs(1)).await;
let chain = certs(&mut std::io::Cursor::new(*chain)).unwrap(); let chain = certs(&mut std::io::Cursor::new(*chain)).unwrap();
let trust_anchors = chain let mut root_store = rustls::RootCertStore::empty();
.iter() root_store.add_server_trust_anchors(chain.iter().map(|cert| {
.map(|cert| {
let ta = webpki::TrustAnchor::try_from_cert_der(&cert[..]).unwrap(); let ta = webpki::TrustAnchor::try_from_cert_der(&cert[..]).unwrap();
OwnedTrustAnchor::from_subject_spki_name_constraints( OwnedTrustAnchor::from_subject_spki_name_constraints(
ta.subject, ta.subject,
ta.spki, ta.spki,
ta.name_constraints, ta.name_constraints,
) )
}) }));
.collect::<Vec<_>>();
let mut root_store = rustls::RootCertStore::empty();
root_store.add_server_trust_anchors(trust_anchors.into_iter());
let config = rustls::ClientConfig::builder() let config = rustls::ClientConfig::builder()
.with_safe_defaults() .with_safe_defaults()
.with_root_certificates(root_store) .with_root_certificates(root_store)
@ -140,19 +137,16 @@ async fn fail() -> io::Result<()> {
let (addr, domain, chain) = start_server(); let (addr, domain, chain) = start_server();
let chain = certs(&mut std::io::Cursor::new(*chain)).unwrap(); let chain = certs(&mut std::io::Cursor::new(*chain)).unwrap();
let trust_anchors = chain let mut root_store = rustls::RootCertStore::empty();
.iter() root_store.add_server_trust_anchors(chain.iter().map(|cert| {
.map(|cert| {
let ta = webpki::TrustAnchor::try_from_cert_der(&cert[..]).unwrap(); let ta = webpki::TrustAnchor::try_from_cert_der(&cert[..]).unwrap();
OwnedTrustAnchor::from_subject_spki_name_constraints( OwnedTrustAnchor::from_subject_spki_name_constraints(
ta.subject, ta.subject,
ta.spki, ta.spki,
ta.name_constraints, ta.name_constraints,
) )
}) }));
.collect::<Vec<_>>();
let mut root_store = rustls::RootCertStore::empty();
root_store.add_server_trust_anchors(trust_anchors.into_iter());
let config = rustls::ClientConfig::builder() let config = rustls::ClientConfig::builder()
.with_safe_defaults() .with_safe_defaults()
.with_root_certificates(root_store) .with_root_certificates(root_store)
@ -190,7 +184,7 @@ async fn test_lazy_config_acceptor() -> io::Result<()> {
assert_eq!( assert_eq!(
ch.alpn() ch.alpn()
.map(|protos| protos.collect::<Vec<_>>()) .map(|protos| protos.collect::<Vec<_>>())
.unwrap_or(Vec::new()), .unwrap_or_default(),
Vec::<&[u8]>::new() Vec::<&[u8]>::new()
); );

View File

@ -27,18 +27,15 @@ mod utils {
let mut client_root_cert_store = RootCertStore::empty(); let mut client_root_cert_store = RootCertStore::empty();
let mut chain = BufReader::new(Cursor::new(CHAIN)); let mut chain = BufReader::new(Cursor::new(CHAIN));
let certs = certs(&mut chain).unwrap(); let certs = certs(&mut chain).unwrap();
let trust_anchors = certs client_root_cert_store.add_server_trust_anchors(certs.iter().map(|cert| {
.iter()
.map(|cert| {
let ta = webpki::TrustAnchor::try_from_cert_der(&cert[..]).unwrap(); let ta = webpki::TrustAnchor::try_from_cert_der(&cert[..]).unwrap();
OwnedTrustAnchor::from_subject_spki_name_constraints( OwnedTrustAnchor::from_subject_spki_name_constraints(
ta.subject, ta.subject,
ta.spki, ta.spki,
ta.name_constraints, ta.name_constraints,
) )
}) }));
.collect::<Vec<_>>();
client_root_cert_store.add_server_trust_anchors(trust_anchors.into_iter());
let cconfig = ClientConfig::builder() let cconfig = ClientConfig::builder()
.with_safe_defaults() .with_safe_defaults()
.with_root_certificates(client_root_cert_store) .with_root_certificates(client_root_cert_store)