Start milestone 3
- Add functionality to query online sources (Keyservers, etc) for certificates. - Use introducers to determine which UserIDs should be fetched from online soources. Check certifications before importing certifiactes into the local cert store. - start docker image for local end-to-end testing.
This commit is contained in:
@@ -18,4 +18,6 @@ pub enum HuskError {
|
||||
NoCertStore,
|
||||
#[error("No encryption keys found")]
|
||||
NoEncryptionKeys,
|
||||
#[error("Error while looking up email {0}: {1}")]
|
||||
KeyLookupError(String, String),
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ pub struct HuskContext<'hc> {
|
||||
pub cert_store: CertStore<'hc>,
|
||||
pub local_trust_root: Cert,
|
||||
pub introducers: Vec<Introducer>,
|
||||
pub keyservers: Vec<String>,
|
||||
pub mail: MailContext<'hc>,
|
||||
}
|
||||
|
||||
@@ -43,6 +44,7 @@ impl<'hc> HuskContext<'hc> {
|
||||
cert_store,
|
||||
local_trust_root,
|
||||
introducers,
|
||||
keyservers: config.get_keyservers(),
|
||||
mail: MailContext::new(),
|
||||
})
|
||||
}
|
||||
@@ -55,9 +57,9 @@ impl<'hc> HuskContext<'hc> {
|
||||
self.mail = MailContext::new();
|
||||
}
|
||||
|
||||
pub fn add_recipient(&mut self, rcpt: String) -> anyhow::Result<()> {
|
||||
pub async fn add_recipient(&mut self, rcpt: String) {
|
||||
|
||||
let certs = crypto::get_certificates(&self, rcpt.as_str());
|
||||
let certs = crypto::get_certificates(&self, rcpt.as_str()).await;
|
||||
|
||||
self.mail.add_recipient(rcpt, certs)
|
||||
}
|
||||
|
||||
@@ -29,5 +29,29 @@ impl Introducer {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_introducing(&self, cert: &Cert) -> bool {
|
||||
|
||||
let policy = StandardPolicy::new();
|
||||
let mut result = false;
|
||||
|
||||
let my_keyid = self.cert.keyid();
|
||||
|
||||
if let Ok(vc) = cert.with_policy(&policy, None) {
|
||||
vc.userids()
|
||||
.revoked(false)
|
||||
.for_each(|u| {
|
||||
u.certifications().for_each(|s| {
|
||||
if s.signature_alive(None, None).is_ok() {
|
||||
s.issuers().for_each(|i| {
|
||||
if i == &my_keyid { result = true; }
|
||||
});
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
result
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,13 +44,11 @@ impl<'mc> MailContext<'mc> {
|
||||
self.sender = Some(sender);
|
||||
}
|
||||
|
||||
pub fn add_recipient(&mut self, rcpt: String, certs: Vec<Arc<LazyCert<'mc>>>) -> anyhow::Result<()> {
|
||||
pub fn add_recipient(&mut self, rcpt: String, certs: Vec<Arc<LazyCert<'mc>>>) {
|
||||
let mut recipient: Recipient = rcpt.into();
|
||||
recipient.certs = certs;
|
||||
|
||||
self.recipients.push(recipient);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn add_chunk(&mut self, chunk: Bytes) {
|
||||
|
||||
Reference in New Issue
Block a user