mirror of
https://github.com/stalwartlabs/mail-server.git
synced 2025-10-12 21:45:54 +08:00
Fixed IMAP retrieval of auto-encrypted emails (fixes #203)
This commit is contained in:
parent
f53ef18f61
commit
c7be16692e
4 changed files with 23 additions and 17 deletions
|
@ -87,13 +87,12 @@ pub struct EncryptionParams {
|
||||||
pub certs: Vec<Vec<u8>>,
|
pub certs: Vec<Vec<u8>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait::async_trait]
|
#[allow(async_fn_in_trait)]
|
||||||
pub trait EncryptMessage {
|
pub trait EncryptMessage {
|
||||||
async fn encrypt(&self, params: &EncryptionParams) -> Result<Vec<u8>, EncryptMessageError>;
|
async fn encrypt(&self, params: &EncryptionParams) -> Result<Vec<u8>, EncryptMessageError>;
|
||||||
fn is_encrypted(&self) -> bool;
|
fn is_encrypted(&self) -> bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait::async_trait]
|
|
||||||
impl EncryptMessage for Message<'_> {
|
impl EncryptMessage for Message<'_> {
|
||||||
async fn encrypt(&self, params: &EncryptionParams) -> Result<Vec<u8>, EncryptMessageError> {
|
async fn encrypt(&self, params: &EncryptionParams) -> Result<Vec<u8>, EncryptMessageError> {
|
||||||
let root = self.root_part();
|
let root = self.root_part();
|
||||||
|
|
|
@ -31,7 +31,7 @@ use jmap_proto::{
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use mail_parser::{
|
use mail_parser::{
|
||||||
parsers::fields::thread::thread_name, HeaderName, HeaderValue, Message, PartType,
|
parsers::fields::thread::thread_name, HeaderName, HeaderValue, Message, MessageParser, PartType,
|
||||||
};
|
};
|
||||||
|
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
|
@ -221,6 +221,12 @@ impl JMAP {
|
||||||
Ok(new_raw_message) => {
|
Ok(new_raw_message) => {
|
||||||
raw_message = Cow::from(new_raw_message);
|
raw_message = Cow::from(new_raw_message);
|
||||||
raw_message_len = raw_message.len() as i64;
|
raw_message_len = raw_message.len() as i64;
|
||||||
|
message = MessageParser::default()
|
||||||
|
.parse(raw_message.as_ref())
|
||||||
|
.ok_or_else(|| IngestError::Permanent {
|
||||||
|
code: [5, 5, 0],
|
||||||
|
reason: "Failed to parse encrypted e-mail message.".to_string(),
|
||||||
|
})?;
|
||||||
|
|
||||||
// Remove contents from parsed message
|
// Remove contents from parsed message
|
||||||
for part in &mut message.parts {
|
for part in &mut message.parts {
|
||||||
|
|
|
@ -10,9 +10,10 @@ database = "stalwart"
|
||||||
user = "root"
|
user = "root"
|
||||||
password = "password"
|
password = "password"
|
||||||
disable = true
|
disable = true
|
||||||
|
#max-allowed-packet = 1073741824
|
||||||
|
|
||||||
[store."mysql".timeout]
|
#[store."mysql".timeout]
|
||||||
wait = "15s"
|
#wait = "15s"
|
||||||
|
|
||||||
#[store."mysql".pool]
|
#[store."mysql".pool]
|
||||||
#max-connections = 10
|
#max-connections = 10
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
|
|
||||||
cargo run -p stalwart-cli -- -u https://127.0.0.1:443 -c admin:secret domain create example.org
|
cargo run -p stalwart-cli -- -u https://127.0.0.1:443 -c admin:secret domain create example.org
|
||||||
cargo run -p stalwart-cli -- -u https://127.0.0.1:443 -c admin:secret account create john 12345 -d "John Doe" -a john@example.org -a john.doe@example.org
|
cargo run -p stalwart-cli -- -u https://127.0.0.1:443 -c admin:secret account create john 12345 -d "John Doe" -a john@example.org -a john.doe@example.org
|
||||||
#cargo run -p stalwart-cli -- -u https://127.0.0.1:8080 -c admin:secret account create jane abcde -d "Jane Doe" -a jane@example.org
|
#cargo run -p stalwart-cli -- -u https://127.0.0.1:443 -c admin:secret account create jane abcde -d "Jane Doe" -a jane@example.org
|
||||||
#cargo run -p stalwart-cli -- -u https://127.0.0.1:8080 -c admin:secret account create bill xyz12 -d "Bill Foobar" -a bill@example.org
|
#cargo run -p stalwart-cli -- -u https://127.0.0.1:443 -c admin:secret account create bill xyz12 -d "Bill Foobar" -a bill@example.org
|
||||||
#cargo run -p stalwart-cli -- -u https://127.0.0.1:8080 -c admin:secret group create sales -d "Sales Department"
|
#cargo run -p stalwart-cli -- -u https://127.0.0.1:443 -c admin:secret group create sales -d "Sales Department"
|
||||||
#cargo run -p stalwart-cli -- -u https://127.0.0.1:8080 -c admin:secret group create support -d "Technical Support"
|
#cargo run -p stalwart-cli -- -u https://127.0.0.1:443 -c admin:secret group create support -d "Technical Support"
|
||||||
#cargo run -p stalwart-cli -- -u https://127.0.0.1:8080 -c admin:secret account add-to-group john sales support
|
#cargo run -p stalwart-cli -- -u https://127.0.0.1:443 -c admin:secret account add-to-group john sales support
|
||||||
#cargo run -p stalwart-cli -- -u https://127.0.0.1:8080 -c admin:secret account remove-from-group john support
|
#cargo run -p stalwart-cli -- -u https://127.0.0.1:443 -c admin:secret account remove-from-group john support
|
||||||
#cargo run -p stalwart-cli -- -u https://127.0.0.1:8080 -c admin:secret account add-email jane jane.doe@example.org
|
#cargo run -p stalwart-cli -- -u https://127.0.0.1:443 -c admin:secret account add-email jane jane.doe@example.org
|
||||||
#cargo run -p stalwart-cli -- -u https://127.0.0.1:8080 -c admin:secret list create everyone everyone@example.org
|
#cargo run -p stalwart-cli -- -u https://127.0.0.1:443 -c admin:secret list create everyone everyone@example.org
|
||||||
#cargo run -p stalwart-cli -- -u https://127.0.0.1:8080 -c admin:secret list add-members everyone jane john bill
|
#cargo run -p stalwart-cli -- -u https://127.0.0.1:443 -c admin:secret list add-members everyone jane john bill
|
||||||
#cargo run -p stalwart-cli -- -u https://127.0.0.1:8080 -c admin:secret account list
|
#cargo run -p stalwart-cli -- -u https://127.0.0.1:443 -c admin:secret account list
|
||||||
#cargo run -p stalwart-cli -- -u https://127.0.0.1:8080 -c admin:secret import messages --format mbox john _ignore/dovecot-crlf
|
#cargo run -p stalwart-cli -- -u https://127.0.0.1:443 -c admin:secret import messages --format mbox john _ignore/dovecot-crlf
|
||||||
#cargo run -p stalwart-cli -- -u https://127.0.0.1:8080 -c admin:secret import messages --format maildir john /var/mail/john
|
#cargo run -p stalwart-cli -- -u https://127.0.0.1:443 -c admin:secret import messages --format maildir john /var/mail/john
|
||||||
|
|
Loading…
Add table
Reference in a new issue