S/MIME don't post identity key and certificate, just fetch from server

This commit is contained in:
the-djmaze 2024-03-04 15:01:47 +01:00
parent 4006dd38f8
commit 574fd820a6
3 changed files with 25 additions and 12 deletions

View file

@ -69,7 +69,7 @@ export const GnuPGUserStore = new class {
}
};
if (isPrivate) {
key.password = async (btnTxt = 'CRYPTO/SIGN') => {
key.password = async btnTxt => {
const pass = await Passphrases.ask(key,
'GnuPG key<br>' + key.id + ' ' + key.emails[0],
btnTxt
@ -228,7 +228,7 @@ export const GnuPGUserStore = new class {
}
async sign(privateKey) {
return await privateKey.password();
return await privateKey.password('CRYPTO/SIGN');
}
};

View file

@ -1561,12 +1561,13 @@ export class ComposePopupView extends AbstractViewPopup {
}
if ('S/MIME' == signOptions[i][0]) {
// TODO: sign in PHP fails
params.signCertificate = identity.smimeCertificate();
params.signPrivateKey = identity.smimeKey();
params.sign = 'S/MIME';
// params.signCertificate = identity.smimeCertificate();
// params.signPrivateKey = identity.smimeKey();
if (identity.smimeKeyEncrypted()) {
const pass = await Passphrases.ask(identity,
i18n('SMIME/PRIVATE_KEY_OF', {EMAIL: identity.email()}),
'CRYPTO/DECRYPT'
'CRYPTO/SIGN'
);
if (null != pass) {
params.signPassphrase = pass.password;

View file

@ -930,14 +930,15 @@ trait Messages
$oMessage->DoesNotAddDefaultXMailer();
}
$sFrom = $this->GetActionParam('from', '');
$oMessage->SetFrom(\MailSo\Mime\Email::Parse($sFrom));
$oMessage->SetFrom(\MailSo\Mime\Email::Parse($this->GetActionParam('from', '')));
$oFrom = $oMessage->GetFrom();
/*
$oFromIdentity = $this->GetIdentityByID($oAccount, $this->GetActionParam('identityID', ''));
if ($oFromIdentity)
$oIdentity = $this->GetIdentityByID($oAccount, $this->GetActionParam('identityID', ''));
if ($oIdentity)
{
$oMessage->SetFrom(new \MailSo\Mime\Email(
$oFromIdentity->Email(), $oFromIdentity->Name()));
$oIdentity->Email(), $oIdentity->Name()));
if ($oAccount->Domain()->OutSetSender()) {
$oMessage->SetSender(\MailSo\Mime\Email::Parse($oAccount->Email()));
}
@ -947,14 +948,13 @@ trait Messages
$oMessage->SetFrom(\MailSo\Mime\Email::Parse($oAccount->Email()));
}
*/
$oFrom = $oMessage->GetFrom();
$oMessage->RegenerateMessageId($oFrom ? $oFrom->GetDomain() : '');
$oMessage->SetReplyTo(new \MailSo\Mime\EmailCollection($this->GetActionParam('replyTo', '')));
if (!empty($this->GetActionParam('readReceiptRequest', 0))) {
// Read Receipts Reference Main Account Email, Not Identities #147
// $oMessage->SetReadReceipt(($oFromIdentity ?: $oAccount)->Email());
// $oMessage->SetReadReceipt(($oIdentity ?: $oAccount)->Email());
$oMessage->SetReadReceipt($oFrom->GetEmail());
}
@ -1169,6 +1169,18 @@ trait Messages
} else {
$sCertificate = $this->GetActionParam('signCertificate', '');
$sPrivateKey = $this->GetActionParam('signPrivateKey', '');
if ('S/MIME' === $this->GetActionParam('sign', '')) {
$sID = $this->GetActionParam('identityID', '');
foreach ($this->GetIdentities($oAccount) as $oIdentity) {
if ($oIdentity && $oIdentity->smimeCertificate && $oIdentity->smimeKey
&& ($oIdentity->Id() === $sID || $oIdentity->Email() === $oFrom->GetEmail())
) {
$sCertificate = $oIdentity->smimeCertificate;
$sPrivateKey = $oIdentity->smimeKey;
break;
}
}
}
if ($sCertificate && $sPrivateKey) {
$oBody = $oMessage->GetRootPart();