commit 27aae35b0e4fde7f70b8c9d97ee8fcd572ca14d5
parent d51f33cd96f2c7ab4e5b9d9c1804cb2213cfaee1
Author: Dylan ross <dylan.ssor@gmail.com>
Date: Mon, 12 Jun 2023 11:40:29 -0700
adds ManifestStoreReport::cert_chain (#265)
Co-authored-by: Dylan Ross <dyross@adobe.com>
Diffstat:
1 file changed, 30 insertions(+), 3 deletions(-)
diff --git a/sdk/src/manifest_store_report.rs b/sdk/src/manifest_store_report.rs
@@ -94,17 +94,25 @@ impl ManifestStoreReport {
Ok(())
}
- /// Prints the certificate chain use to sign the active manifest
+ /// Prints the certificate chain used to sign the active manifest.
#[cfg(feature = "file_io")]
pub fn dump_cert_chain<P: AsRef<Path>>(path: P) -> Result<()> {
- let mut validation_log = crate::status_tracker::DetailedStatusTracker::new();
- let store = crate::store::Store::load_from_asset(path.as_ref(), true, &mut validation_log)?;
+ let mut validation_log = DetailedStatusTracker::new();
+ let store = Store::load_from_asset(path.as_ref(), true, &mut validation_log)?;
let cert_str = store.get_provenance_cert_chain()?;
println!("{cert_str}");
Ok(())
}
+ /// Returns the certificate chain used to to sign the active manifest.
+ #[cfg(feature = "file_io")]
+ pub fn cert_chain<P: AsRef<Path>>(path: P) -> Result<String> {
+ let mut validation_log = DetailedStatusTracker::new();
+ let store = Store::load_from_asset(path.as_ref(), true, &mut validation_log)?;
+ store.get_provenance_cert_chain()
+ }
+
/// Creates a ManifestStoreReport from an existing Store and a validation log
pub(crate) fn from_store_with_log(
store: &Store,
@@ -395,4 +403,23 @@ mod tests {
ManifestStoreReport::dump_cert_chain(path).expect("dump certs");
}
+
+ #[test]
+ #[cfg(feature = "file_io")]
+ fn manifest_get_certchain() {
+ let asset_name = "CA.jpg";
+ let path = fixture_path(asset_name);
+ assert!(ManifestStoreReport::cert_chain(path).is_ok())
+ }
+
+ #[test]
+ #[cfg(feature = "file_io")]
+ fn manifest_get_certchain_no_manifest_err() {
+ let asset_name = "no_manifest.jpg";
+ let path = fixture_path(asset_name);
+ assert!(matches!(
+ ManifestStoreReport::cert_chain(path),
+ Err(crate::Error::JumbfNotFound)
+ ))
+ }
}