Skip to content

Commit

Permalink
chore(tools): update jet-doctor
Browse files Browse the repository at this point in the history
  • Loading branch information
CBenoit committed Sep 27, 2024
1 parent 6506b08 commit effd12f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-tools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -219,4 +219,4 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.tool }}-${{ matrix.arch }}-${{ matrix.platform }}
path: ${{ matrix.tool }}.dmg
path: ${{ matrix.tool }}.dmg
12 changes: 6 additions & 6 deletions tools/jet-doctor/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "jet-doctor"
version = "0.1.0"
version = "0.2.0"
authors = ["Devolutions Inc. <[email protected]>"]
edition = "2021"
publish = false
Expand All @@ -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"
18 changes: 8 additions & 10 deletions tools/jet-doctor/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}");
}
}
Expand Down Expand Up @@ -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")?;
}

Expand Down

0 comments on commit effd12f

Please sign in to comment.