From 97391a3f337566cbc68c44a925b105deb639ef1c Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Tue, 21 May 2024 17:47:24 +0200 Subject: [PATCH] Changes for #1587 --- dev/View/Popup/Compose.js | 6 ++ .../libraries/RainLoop/Actions/Messages.php | 58 ++++++++++++++++++- 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/dev/View/Popup/Compose.js b/dev/View/Popup/Compose.js index 6335ecd02..ac774d725 100644 --- a/dev/View/Popup/Compose.js +++ b/dev/View/Popup/Compose.js @@ -1566,6 +1566,10 @@ export class ComposePopupView extends AbstractViewPopup { params.signed = signed.toString(); params.boundary = signed.boundary; data = signed; +/* + Object.entries(PgpUserStore.getPublicKeyOfEmails([getEmail(this.from())]) || {}) + .forEach(([k,v]) => params.publicKey = v); +*/ } catch (e) { sign = false; console.error(e); @@ -1579,6 +1583,7 @@ export class ComposePopupView extends AbstractViewPopup { // params.signData = data.toString(); params.signFingerprint = signOptions[i][1].fingerprint; params.signPassphrase = pass; +// params.attachPublicKey = false; } else { sign = false; } @@ -1589,6 +1594,7 @@ export class ComposePopupView extends AbstractViewPopup { params.sign = 'S/MIME'; // params.signCertificate = identity.smimeCertificate(); // params.signPrivateKey = identity.smimeKey(); +// params.attachCertificate = false; if (identity.smimeKeyEncrypted()) { const pass = await Passphrases.ask(identity, i18n('SMIME/PRIVATE_KEY_OF', {EMAIL: identity.email()}), diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Messages.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Messages.php index b630d8ba0..f75be7a1d 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Messages.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Messages.php @@ -1145,7 +1145,25 @@ trait Messages } } } - +/* + // OpenPGP https://github.com/the-djmaze/snappymail/issues/1587 + $sPublicKey = $this->GetActionParam('publicKey', ''); + if ($sPublicKey) { + $oMessage->Attachments()->append( + new \MailSo\Mime\Attachment( + \fopen("data://text/plain,{$sPublicKey}", 'r'), + 'OpenPGP_'.\md5($sPublicKey).'.asc', + \strlen($sPublicKey), + false, + false, + '', + array(), + '', + 'application/pgp-keys' + ) + ); + } +*/ foreach ($aFoundDataURL as $sCidHash => $sDataUrlString) { $aMatch = array(); $sCID = '<'.$sCidHash.'>'; @@ -1171,9 +1189,29 @@ trait Messages $oPassphrase = new \SnappyMail\SensitiveString($this->GetActionParam('signPassphrase', '')); + // GnuPG $sFingerprint = $this->GetActionParam('signFingerprint', ''); if ($sFingerprint) { $GPG = $this->GnuPG(); +/* + // https://github.com/the-djmaze/snappymail/issues/1587 + if ($this->GetActionParam('attachPublicKey', false)) { + $sPublicKey = $GPG->export($sFingerprint); + $oMessage->Attachments()->append( + new \MailSo\Mime\Attachment( + \fopen("data://text/plain,{$sPublicKey}", 'r'), + "OpenPGP_0x{$sFingerprint}.asc", + \strlen($sPublicKey), + false, + false, + '', + array(), + '', + 'application/pgp-keys' + ) + ); + } +*/ $oBody = $oMessage->GetRootPart(); $resource = $oBody->ToStream(); @@ -1225,6 +1263,24 @@ trait Messages } } } +/* + // https://github.com/the-djmaze/snappymail/issues/1587 + if ($sCertificate && $this->GetActionParam('attachCertificate', false)) { + $oMessage->Attachments()->append( + new \MailSo\Mime\Attachment( + \fopen("data://text/plain,{$sCertificate}", 'r'), + 'certificate.pem', + \strlen($sCertificate), + false, + false, + '', + array(), + '', + 'application/pem-certificate-chain' + ) + ); + } +*/ if ($sCertificate && $sPrivateKey) { $oBody = $oMessage->GetRootPart();