This commit is contained in:
the-djmaze 2024-05-21 17:47:24 +02:00
parent c3c75c216b
commit 97391a3f33
2 changed files with 63 additions and 1 deletions

View file

@ -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()}),

View file

@ -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();