From effd12f03d3f165661c2daa744361f5ff81be987 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20CORTIER?= Date: Fri, 27 Sep 2024 17:43:02 +0900 Subject: [PATCH] chore(tools): update jet-doctor --- .github/workflows/build-tools.yml | 2 +- tools/jet-doctor/Cargo.toml | 12 ++++++------ tools/jet-doctor/src/main.rs | 18 ++++++++---------- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/.github/workflows/build-tools.yml b/.github/workflows/build-tools.yml index 76911431a..0e8dfb319 100644 --- a/.github/workflows/build-tools.yml +++ b/.github/workflows/build-tools.yml @@ -219,4 +219,4 @@ jobs: uses: actions/upload-artifact@v4 with: name: ${{ matrix.tool }}-${{ matrix.arch }}-${{ matrix.platform }} - path: ${{ matrix.tool }}.dmg \ No newline at end of file + path: ${{ matrix.tool }}.dmg diff --git a/tools/jet-doctor/Cargo.toml b/tools/jet-doctor/Cargo.toml index 5f924ebc3..e1cb2c193 100644 --- a/tools/jet-doctor/Cargo.toml +++ b/tools/jet-doctor/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "jet-doctor" -version = "0.1.0" +version = "0.2.0" authors = ["Devolutions Inc. "] edition = "2021" publish = false @@ -16,11 +16,11 @@ pem = "3.0" shadow-rs = "0.21" openssl-probe = "0.1" -# Same dependency as tokio-tungstenite 0.20 -# https://crates.io/crates/tokio-tungstenite/0.20.1/dependencies -rustls-webpki = "0.101" -rustls = "0.21" -rustls-native-certs = "0.6" +# Same dependency as tokio-tungstenite 0.21.0 +# https://crates.io/crates/tokio-tungstenite/0.21.0/dependencies +rustls-webpki = "0.102" +rustls = "0.22" +rustls-native-certs = "0.7" [build-dependencies] shadow-rs = "0.21" diff --git a/tools/jet-doctor/src/main.rs b/tools/jet-doctor/src/main.rs index 376eff632..a7fb857bc 100644 --- a/tools/jet-doctor/src/main.rs +++ b/tools/jet-doctor/src/main.rs @@ -89,12 +89,11 @@ fn check_root_store(mut out: impl fmt::Write) -> anyhow::Result<()> { let mut root_store = rustls::RootCertStore::empty(); for cert in rustls_native_certs::load_native_certs().context("failed to load native certificates")? { - let cert = rustls::Certificate(cert.0); - - if let Err(e) = root_store.add(&cert) { + let cert_der = cert.to_vec(); + if let Err(e) = root_store.add(cert) { output!(out, "Invalid root certificate: {e}"); - let pem = pem::Pem::new("CERTIFICATE", cert.0); + let pem = pem::Pem::new("CERTIFICATE", cert_der); output!(out, "{pem}"); } } @@ -128,20 +127,19 @@ fn check_cert(mut out: impl fmt::Write, cert_path: &Path, subject_name: Option<& } }; + let cert = rustls::pki_types::CertificateDer::from(cert_der); + output!(out, "Decode end entity certificate"); - let end_entity_cert = - webpki::EndEntityCert::try_from(cert_der.as_slice()).context("decode end entity certificate")?; + let end_entity_cert = webpki::EndEntityCert::try_from(&cert).context("decode end entity certificate")?; if let Some(subject_name) = subject_name { output!(out, "Verify validity for DNS name"); - let subject_name = webpki::SubjectNameRef::try_from_ascii_str(subject_name) - .ok() - .context("invalid subject name")?; + let subject_name = rustls::pki_types::ServerName::try_from(subject_name).context("invalid DNS name")?; end_entity_cert - .verify_is_valid_for_subject_name(subject_name) + .verify_is_valid_for_subject_name(&subject_name) .context("verify DNS name")?; }