Skip to content

Commit 74140d4

Browse files
committed
update deps
1 parent 6dc7b8a commit 74140d4

File tree

3 files changed

+29
-39
lines changed

3 files changed

+29
-39
lines changed

.github/workflows/check.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
name: Check
22

33
on:
4-
push:
5-
branches: [ "master" ]
6-
pull_request:
7-
branches: [ "master" ]
4+
[push, pull_request]
85

96
env:
107
CARGO_TERM_COLOR: always

Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,17 @@ serde = { version = "1.0", features = ["derive"] }
3535
serde_json = "1.0"
3636
socks5-impl = "0.5"
3737
thiserror = "1.0"
38-
tokio = { version = "1.34", features = ["full"] }
38+
tokio = { version = "1.35", features = ["full"] }
3939
tokio-rustls = "0.24"
40-
tokio-tungstenite = { version = "0.20", features = ["rustls-tls-webpki-roots"] }
40+
tokio-tungstenite = { version = "0.21", features = ["rustls-tls-webpki-roots"] }
4141
trust-dns-proto = "0.23"
42-
tungstenite = { version = "0.20", features = ["rustls-tls-webpki-roots"] }
43-
url = "2.4"
42+
tungstenite = { version = "0.21", features = ["rustls-tls-webpki-roots"] }
43+
url = "2.5"
4444
webpki = { package = "rustls-webpki", version = "0.101", features = [
4545
"alloc",
4646
"std",
4747
] }
48-
webpki-roots = "0.25"
48+
webpki-roots = "0.26"
4949

5050
[target.'cfg(target_family="unix")'.dependencies]
5151
daemonize = "0.5"

src/tls.rs

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
use crate::error::{Error, Result};
2-
use rustls_pemfile::{certs, rsa_private_keys};
1+
use crate::error::Result;
32
use std::{
43
fs::File,
54
io::BufReader,
@@ -33,30 +32,28 @@ pub(crate) fn retrieve_root_cert_store_for_client(cafile: &Option<PathBuf>) -> R
3332
}
3433
}
3534
if !done {
36-
root_cert_store.add_trust_anchors(
37-
webpki_roots::TLS_SERVER_ROOTS
38-
.iter()
39-
.map(|ta| OwnedTrustAnchor::from_subject_spki_name_constraints(ta.subject, ta.spki, ta.name_constraints)),
40-
);
35+
root_cert_store.add_trust_anchors(webpki_roots::TLS_SERVER_ROOTS.iter().map(|ta| {
36+
let name_constraints = ta.name_constraints.clone().map(|nc| nc.as_ref().to_vec());
37+
OwnedTrustAnchor::from_subject_spki_name_constraints(ta.subject.as_ref(), ta.subject_public_key_info.as_ref(), name_constraints)
38+
}));
4139
}
4240
Ok(root_cert_store)
4341
}
4442

45-
mod danger {
46-
pub struct NoCertificateVerification {}
43+
#[derive(Debug)]
44+
pub struct NoCertificateVerification {}
4745

48-
impl rustls::client::ServerCertVerifier for NoCertificateVerification {
49-
fn verify_server_cert(
50-
&self,
51-
_end_entity: &rustls::Certificate,
52-
_intermediates: &[rustls::Certificate],
53-
_server_name: &rustls::ServerName,
54-
_scts: &mut dyn Iterator<Item = &[u8]>,
55-
_ocsp: &[u8],
56-
_now: std::time::SystemTime,
57-
) -> Result<rustls::client::ServerCertVerified, rustls::Error> {
58-
Ok(rustls::client::ServerCertVerified::assertion())
59-
}
46+
impl rustls::client::ServerCertVerifier for NoCertificateVerification {
47+
fn verify_server_cert(
48+
&self,
49+
_end_entity: &rustls::Certificate,
50+
_intermediates: &[rustls::Certificate],
51+
_server_name: &rustls::ServerName,
52+
_scts: &mut dyn Iterator<Item = &[u8]>,
53+
_ocsp: &[u8],
54+
_now: std::time::SystemTime,
55+
) -> Result<rustls::client::ServerCertVerified, rustls::Error> {
56+
Ok(rustls::client::ServerCertVerified::assertion())
6057
}
6158
}
6259

@@ -69,9 +66,7 @@ pub(crate) async fn create_tls_client_stream(
6966
.with_safe_defaults()
7067
.with_root_certificates(root_cert_store)
7168
.with_no_client_auth();
72-
config
73-
.dangerous()
74-
.set_certificate_verifier(Arc::new(danger::NoCertificateVerification {}));
69+
config.dangerous().set_certificate_verifier(Arc::new(NoCertificateVerification {}));
7570
let connector = TlsConnector::from(std::sync::Arc::new(config));
7671

7772
let stream = crate::tcp_stream::create(addr).await?;
@@ -84,13 +79,11 @@ pub(crate) async fn create_tls_client_stream(
8479
}
8580

8681
pub(crate) fn server_load_certs(path: &Path) -> Result<Vec<Certificate>> {
87-
certs(&mut BufReader::new(File::open(path)?))
88-
.map_err(|e| Error::from(format!("Certificate error: {e}")))
89-
.map(|mut certs| certs.drain(..).map(Certificate).collect())
82+
let certs = rustls_pemfile::certs(&mut BufReader::new(File::open(path)?))?;
83+
Ok(certs.into_iter().map(Certificate).collect())
9084
}
9185

9286
pub(crate) fn server_load_keys(path: &Path) -> Result<Vec<PrivateKey>> {
93-
rsa_private_keys(&mut BufReader::new(File::open(path)?))
94-
.map_err(|e| Error::from(format!("PrivateKey error: {e}")))
95-
.map(|mut keys| keys.drain(..).map(PrivateKey).collect())
87+
let keys = rustls_pemfile::rsa_private_keys(&mut BufReader::new(File::open(path)?))?;
88+
Ok(keys.into_iter().map(PrivateKey).collect())
9689
}

0 commit comments

Comments
 (0)