mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-11-10 09:02:45 +08:00
Improved signing messages by allowing to choose between the options
This commit is contained in:
parent
c2e558c9b1
commit
6d15cabfe5
1 changed files with 16 additions and 16 deletions
|
@ -500,7 +500,7 @@ export class ComposePopupView extends AbstractViewPopup {
|
|||
this.sendError(true);
|
||||
this.sendErrorDesc(
|
||||
getNotification(iError, data?.ErrorMessage, Notifications.CantSendMessage)
|
||||
+ "\n" + data?.ErrorMessageAdditional
|
||||
+ "\n" + (data?.ErrorMessageAdditional || data?.ErrorMessage)
|
||||
);
|
||||
};
|
||||
try {
|
||||
|
@ -535,9 +535,13 @@ export class ComposePopupView extends AbstractViewPopup {
|
|||
}
|
||||
this.savedErrorDesc(msg);
|
||||
} else {
|
||||
params.signPassphrase && Passphrases.delete(identity);
|
||||
this.sendError(true);
|
||||
sendFailed(iError, data);
|
||||
// Remove remembered passphrase as it could be wrong
|
||||
let key = ('S/MIME' === params.sign) ? identity : null;
|
||||
params.signFingerprint
|
||||
&& this.signOptions.forEach(option => ('GnuPG' === option[0]) && (key = option[1]));
|
||||
key && Passphrases.delete(key);
|
||||
}
|
||||
} else {
|
||||
if (arrayLength(this.aDraftInfo) > 0) {
|
||||
|
@ -1546,12 +1550,11 @@ export class ComposePopupView extends AbstractViewPopup {
|
|||
alternative.children.push(data);
|
||||
data = alternative;
|
||||
}
|
||||
let sign = true;
|
||||
let isSigned = false;
|
||||
for (let i = 0; i < signOptions.length; ++i) {
|
||||
if ('OpenPGP' == signOptions[i][0]) {
|
||||
try {
|
||||
// Doesn't sign attachments
|
||||
params.html = params.plain = '';
|
||||
let signed = new MimePart;
|
||||
signed.headers['Content-Type'] =
|
||||
'multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"';
|
||||
|
@ -1562,6 +1565,8 @@ export class ComposePopupView extends AbstractViewPopup {
|
|||
signature.headers['Content-Transfer-Encoding'] = '7Bit';
|
||||
signature.body = await OpenPGPUserStore.sign(data.toString(), signOptions[i][1], 1);
|
||||
signed.children.push(signature);
|
||||
isSigned = true;
|
||||
params.html = params.plain = '';
|
||||
params.signed = signed.toString();
|
||||
params.boundary = signed.boundary;
|
||||
data = signed;
|
||||
|
@ -1569,13 +1574,11 @@ export class ComposePopupView extends AbstractViewPopup {
|
|||
Object.entries(PgpUserStore.getPublicKeyOfEmails([getEmail(this.from())]) || {})
|
||||
.forEach(([k,v]) => params.publicKey = v);
|
||||
*/
|
||||
break;
|
||||
} catch (e) {
|
||||
sign = false;
|
||||
console.error(e);
|
||||
}
|
||||
break;
|
||||
}
|
||||
if ('GnuPG' == signOptions[i][0]) {
|
||||
} else if ('GnuPG' == signOptions[i][0]) {
|
||||
// TODO: sign in PHP fails
|
||||
let pass = await GnuPGUserStore.sign(signOptions[i][1]);
|
||||
if (null != pass) {
|
||||
|
@ -1583,12 +1586,10 @@ export class ComposePopupView extends AbstractViewPopup {
|
|||
params.signFingerprint = signOptions[i][1].fingerprint;
|
||||
params.signPassphrase = pass;
|
||||
// params.attachPublicKey = false;
|
||||
} else {
|
||||
sign = false;
|
||||
}
|
||||
isSigned = true;
|
||||
break;
|
||||
}
|
||||
if ('S/MIME' == signOptions[i][0]) {
|
||||
} else if ('S/MIME' == signOptions[i][0]) {
|
||||
// TODO: sign in PHP fails
|
||||
params.sign = 'S/MIME';
|
||||
// params.signCertificate = identity.smimeCertificate();
|
||||
|
@ -1602,13 +1603,12 @@ export class ComposePopupView extends AbstractViewPopup {
|
|||
if (null != pass) {
|
||||
params.signPassphrase = pass.password;
|
||||
pass.remember && Passphrases.handle(identity, pass.password);
|
||||
} else {
|
||||
sign = false;
|
||||
isSigned = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (signOptions.length && !sign) {
|
||||
if (signOptions.length && !isSigned) {
|
||||
throw 'Signing failed';
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue