#89 verify PGP signatures using OpenPGP.js

This commit is contained in:
the-djmaze 2022-02-02 15:24:32 +01:00
parent 93db6e6e0e
commit da79feeaee
5 changed files with 93 additions and 72 deletions

View file

@ -457,9 +457,9 @@ class ComposePopupView extends AbstractViewPopup {
data: params.Text,
};
if ('openpgp' == sign) {
let privateKey;
let privateKey, sender = this.currentIdentity().email();
try {
const key = OpenPGPUserStore.getPrivateKeyFor(this.currentIdentity().email());
const key = OpenPGPUserStore.getPrivateKeyFor(sender);
if (key) {
key.decrypt(window.prompt('Passphrase'));
cfg.privateKey = privateKey = key;
@ -470,7 +470,7 @@ class ComposePopupView extends AbstractViewPopup {
}
if (!privateKey) {
this.sendError(true);
this.sendErrorDesc(i18n('PGP_NOTIFICATIONS/NO_PRIVATE_KEY_FOUND'));
this.sendErrorDesc(i18n('PGP_NOTIFICATIONS/NO_PRIVATE_KEY_FOUND_FOR', { EMAIL: sender }));
return;
}
}

View file

@ -641,10 +641,26 @@ export class MailMessageView extends AbstractViewRight {
pgpVerify(/*self, event*/) {
const oMessage = currentMessage()/*, ctrl = event.target.closest('.openpgp-control')*/;
PgpUserStore.verify(oMessage).then(result => {
console.dir({result:result});
if (result) {
oMessage.pgpVerified(result);
}
/*
if (result && result.success) {
i18n('PGP_NOTIFICATIONS/GOOD_SIGNATURE', {
USER: validKey.user + ' (' + validKey.id + ')'
});
message.getText()
} else {
const keyIds = arrayLength(signingKeyIds) ? signingKeyIds : null,
additional = keyIds
? keyIds.map(item => (item && item.toHex ? item.toHex() : null)).filter(v => v).join(', ')
: '';
i18n('PGP_NOTIFICATIONS/PGP_ERROR', {
ERROR: 'message'
}) + (additional ? ' (' + additional + ')' : '');
}
*/
});
}