commit ca3df05381f5bccb864502d09274432aa37e6018
parent 0769dfb8f78501dce864a2bb248c476198d2189d
Author: mklein13 <michaelsklein13@gmail.com>
Date: Tue, 30 Apr 2024 16:52:43 -0400
Async Signer: add support for async OCSP call (#458)
Co-authored-by: klein <klein@adobe.com>
Co-authored-by: Gavin Peacock <gpeacock@adobe.com>
Diffstat:
3 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/sdk/src/cose_sign.rs b/sdk/src/cose_sign.rs
@@ -204,7 +204,12 @@ fn build_headers(signer: &dyn Signer, data: &[u8], alg: SigningAlg) -> Result<(H
};
let certs = signer.certs()?;
- let ocsp_val = signer.ocsp_val();
+
+ let ocsp_val = if _sync {
+ signer.ocsp_val()
+ } else {
+ signer.ocsp_val().await
+ };
let sc_der_array_or_bytes = match certs.len() {
1 => Value::Bytes(certs[0].clone()), // single cert
diff --git a/sdk/src/openssl/temp_signer_async.rs b/sdk/src/openssl/temp_signer_async.rs
@@ -95,7 +95,7 @@ impl crate::AsyncSigner for AsyncSignerAdapter {
self.tsa_url.clone()
}
- fn ocsp_val(&self) -> Option<Vec<u8>> {
+ async fn ocsp_val(&self) -> Option<Vec<u8>> {
self.ocsp_val.clone()
}
}
diff --git a/sdk/src/signer.rs b/sdk/src/signer.rs
@@ -157,7 +157,7 @@ pub trait AsyncSigner: Sync {
/// This is the only C2PA supported cert revocation method.
/// By pre-querying the value for a your signing cert the value can
/// be cached taking pressure off of the CA (recommended by C2PA spec)
- fn ocsp_val(&self) -> Option<Vec<u8>> {
+ async fn ocsp_val(&self) -> Option<Vec<u8>> {
None
}