mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03: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.sendError(true);
|
||||||
this.sendErrorDesc(
|
this.sendErrorDesc(
|
||||||
getNotification(iError, data?.ErrorMessage, Notifications.CantSendMessage)
|
getNotification(iError, data?.ErrorMessage, Notifications.CantSendMessage)
|
||||||
+ "\n" + data?.ErrorMessageAdditional
|
+ "\n" + (data?.ErrorMessageAdditional || data?.ErrorMessage)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
|
|
@ -535,9 +535,13 @@ export class ComposePopupView extends AbstractViewPopup {
|
||||||
}
|
}
|
||||||
this.savedErrorDesc(msg);
|
this.savedErrorDesc(msg);
|
||||||
} else {
|
} else {
|
||||||
params.signPassphrase && Passphrases.delete(identity);
|
|
||||||
this.sendError(true);
|
this.sendError(true);
|
||||||
sendFailed(iError, data);
|
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 {
|
} else {
|
||||||
if (arrayLength(this.aDraftInfo) > 0) {
|
if (arrayLength(this.aDraftInfo) > 0) {
|
||||||
|
|
@ -1546,12 +1550,11 @@ export class ComposePopupView extends AbstractViewPopup {
|
||||||
alternative.children.push(data);
|
alternative.children.push(data);
|
||||||
data = alternative;
|
data = alternative;
|
||||||
}
|
}
|
||||||
let sign = true;
|
let isSigned = false;
|
||||||
for (let i = 0; i < signOptions.length; ++i) {
|
for (let i = 0; i < signOptions.length; ++i) {
|
||||||
if ('OpenPGP' == signOptions[i][0]) {
|
if ('OpenPGP' == signOptions[i][0]) {
|
||||||
try {
|
try {
|
||||||
// Doesn't sign attachments
|
// Doesn't sign attachments
|
||||||
params.html = params.plain = '';
|
|
||||||
let signed = new MimePart;
|
let signed = new MimePart;
|
||||||
signed.headers['Content-Type'] =
|
signed.headers['Content-Type'] =
|
||||||
'multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"';
|
'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.headers['Content-Transfer-Encoding'] = '7Bit';
|
||||||
signature.body = await OpenPGPUserStore.sign(data.toString(), signOptions[i][1], 1);
|
signature.body = await OpenPGPUserStore.sign(data.toString(), signOptions[i][1], 1);
|
||||||
signed.children.push(signature);
|
signed.children.push(signature);
|
||||||
|
isSigned = true;
|
||||||
|
params.html = params.plain = '';
|
||||||
params.signed = signed.toString();
|
params.signed = signed.toString();
|
||||||
params.boundary = signed.boundary;
|
params.boundary = signed.boundary;
|
||||||
data = signed;
|
data = signed;
|
||||||
|
|
@ -1569,13 +1574,11 @@ export class ComposePopupView extends AbstractViewPopup {
|
||||||
Object.entries(PgpUserStore.getPublicKeyOfEmails([getEmail(this.from())]) || {})
|
Object.entries(PgpUserStore.getPublicKeyOfEmails([getEmail(this.from())]) || {})
|
||||||
.forEach(([k,v]) => params.publicKey = v);
|
.forEach(([k,v]) => params.publicKey = v);
|
||||||
*/
|
*/
|
||||||
|
break;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
sign = false;
|
|
||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
break;
|
} else if ('GnuPG' == signOptions[i][0]) {
|
||||||
}
|
|
||||||
if ('GnuPG' == signOptions[i][0]) {
|
|
||||||
// TODO: sign in PHP fails
|
// TODO: sign in PHP fails
|
||||||
let pass = await GnuPGUserStore.sign(signOptions[i][1]);
|
let pass = await GnuPGUserStore.sign(signOptions[i][1]);
|
||||||
if (null != pass) {
|
if (null != pass) {
|
||||||
|
|
@ -1583,12 +1586,10 @@ export class ComposePopupView extends AbstractViewPopup {
|
||||||
params.signFingerprint = signOptions[i][1].fingerprint;
|
params.signFingerprint = signOptions[i][1].fingerprint;
|
||||||
params.signPassphrase = pass;
|
params.signPassphrase = pass;
|
||||||
// params.attachPublicKey = false;
|
// params.attachPublicKey = false;
|
||||||
} else {
|
isSigned = true;
|
||||||
sign = false;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ('S/MIME' == signOptions[i][0]) {
|
} else if ('S/MIME' == signOptions[i][0]) {
|
||||||
// TODO: sign in PHP fails
|
// TODO: sign in PHP fails
|
||||||
params.sign = 'S/MIME';
|
params.sign = 'S/MIME';
|
||||||
// params.signCertificate = identity.smimeCertificate();
|
// params.signCertificate = identity.smimeCertificate();
|
||||||
|
|
@ -1602,13 +1603,12 @@ export class ComposePopupView extends AbstractViewPopup {
|
||||||
if (null != pass) {
|
if (null != pass) {
|
||||||
params.signPassphrase = pass.password;
|
params.signPassphrase = pass.password;
|
||||||
pass.remember && Passphrases.handle(identity, pass.password);
|
pass.remember && Passphrases.handle(identity, pass.password);
|
||||||
} else {
|
isSigned = true;
|
||||||
sign = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (signOptions.length && !sign) {
|
if (signOptions.length && !isSigned) {
|
||||||
throw 'Signing failed';
|
throw 'Signing failed';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue