summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--openpgp-ffi/src/cert.rs4
-rw-r--r--openpgp/src/cert/mod.rs19
2 files changed, 6 insertions, 17 deletions
diff --git a/openpgp-ffi/src/cert.rs b/openpgp-ffi/src/cert.rs
index 21f082a6..562f863c 100644
--- a/openpgp-ffi/src/cert.rs
+++ b/openpgp-ffi/src/cert.rs
@@ -327,7 +327,9 @@ fn pgp_cert_alive(errp: Option<&mut *mut crate::error::Error>,
{
let policy = &**policy.ref_raw();
ffi_make_fry_from_errp!(errp);
- ffi_try_status!(cert.ref_raw().alive(policy, maybe_time(when)))
+ let valid_cert = ffi_try_or_status!(
+ cert.ref_raw().with_policy(policy, maybe_time(when)));
+ ffi_try_status!(valid_cert.alive())
}
/// Sets the key to expire at the given time.
diff --git a/openpgp/src/cert/mod.rs b/openpgp/src/cert/mod.rs
index c228b03c..b3ab1ca4 100644
--- a/openpgp/src/cert/mod.rs
+++ b/openpgp/src/cert/mod.rs
@@ -146,8 +146,6 @@ use std::fmt;
use std::ops::{Deref, DerefMut};
use std::time;
-use anyhow::Context;
-
use crate::{
crypto::Signer,
Error,
@@ -771,18 +769,6 @@ impl Cert {
self.merge_packets(vec![sig.into()])
}
- /// Returns whether or not the Cert is alive at `t`.
- pub fn alive<T>(&self, policy: &dyn Policy, t: T) -> Result<()>
-
- where T: Into<Option<time::SystemTime>>
- {
- let t = t.into();
- self.primary_key()
- .with_policy(policy, t).context(
- "primary key rejected by policy")?
- .alive()
- }
-
/// Sets the key to expire in delta seconds.
///
/// Note: the time is relative to the key's creation time, not the
@@ -1667,7 +1653,7 @@ impl<'a> ValidCert<'a> {
/// Returns whether or not the Cert is alive.
pub fn alive(&self) -> Result<()> {
- self.cert.alive(self.policy, self.time)
+ self.primary_key().alive()
}
/// Returns the amalgamated primary key.
@@ -3585,7 +3571,8 @@ Pu1xwz57O4zo1VYf6TqHJzVC3OMvMUM2hhdecMUe5x6GorNaj6g=
"issue-215-expiration-on-direct-key-sig.pgp")).unwrap();
assert_match!(
Error::Expired(_)
- = cert.alive(p, None).unwrap_err().downcast().unwrap());
+ = cert.with_policy(p, None).unwrap().alive()
+ .unwrap_err().downcast().unwrap());
assert_match!(
Error::Expired(_)
= cert.primary_key().with_policy(p, None).unwrap()