Skip to content

Commit 842454f

Browse files
committed
verifier: use pki-playground API to generate test PKI
1 parent 661cd6c commit 842454f

6 files changed

Lines changed: 496 additions & 104 deletions

File tree

Cargo.lock

Lines changed: 117 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ resolver = "2"
1717
anyhow = { version = "1.0.103", default-features = false }
1818
async-trait = "0.1.89"
1919
attest.path = "attest"
20+
camino = { version = "1.2.4", default-features = false }
2021
chrono = { version = "0.4.45", default-features=false }
2122
clap = { version = "4.6.1", features = ["derive", "env"] }
2223
clap-verbosity = "2.1.0"
@@ -36,6 +37,7 @@ log = { version = "0.4.33", features = ["std"] }
3637
miette = { version = "7.6.0", features = ["fancy"] }
3738
p384 = { version = "0.13.1", default-features = false }
3839
pem-rfc7468 = { version = "1.0.0", default-features = false }
40+
pki-playground = { git = "https://github.com/oxidecomputer/pki-playground", rev = "bcd3bf2dfe36468c494eac17463a4e10be366b35" }
3941
rats-corim.git = "https://github.com/oxidecomputer/rats-corim"
4042
ron = "0.8"
4143
rpassword = "7.4.0"

verifier/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ tempfile.workspace = true
2626
thiserror.workspace = true
2727
x509-cert = { workspace = true, default-features = true }
2828

29+
[build-dependencies]
30+
anyhow.workspace = true
31+
camino.workspace = true
32+
pki-playground.workspace = true
2933

3034
[dev-dependencies]
3135
attest-data = { path = "../attest-data", features = ["std", "testing"] }

verifier/build.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// This Source Code Form is subject to the terms of the Mozilla Public
2+
// License, v. 2.0. If a copy of the MPL was not distributed with this
3+
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4+
5+
use anyhow::{anyhow, Context, Result};
6+
use camino::Utf8PathBuf;
7+
use pki_playground::{config, OutputFileExistsBehavior};
8+
9+
use std::env;
10+
11+
fn main() -> Result<()> {
12+
// output directory where we put:
13+
// generated test inputs
14+
let out = Utf8PathBuf::from(
15+
env::var("OUT_DIR").context("Failed to get OUT_DIR")?,
16+
);
17+
18+
let config_path = "test-pki.kdl";
19+
let doc = config::load_and_validate(config_path.as_ref()).map_err(|e| {
20+
anyhow!("Loading config from \"{}\" failed: {e:?}", config_path)
21+
})?;
22+
23+
doc.write_key_pairs(out.clone(), OutputFileExistsBehavior::Skip)
24+
.map_err(|e| anyhow!("write key pairs to {out}: {e:?}"))?;
25+
doc.write_certificates(out.clone(), OutputFileExistsBehavior::Skip)
26+
.map_err(|e| anyhow!("write certificates to {out}: {e:?}"))?;
27+
doc.write_certificate_lists(out.clone(), OutputFileExistsBehavior::Skip)
28+
.map_err(|e| anyhow!("write certificate chains to {out}: {e:?}"))?;
29+
30+
Ok(())
31+
}

0 commit comments

Comments
 (0)