Closed Bug 1621128 Opened 5 years ago Closed 5 years ago

Change OpenPGP to use the configured key

Categories

(MailNews Core :: Security: OpenPGP, enhancement)

enhancement
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
Thunderbird 76.0

People

(Reporter: KaiE, Assigned: KaiE)

References

(Blocks 2 open bugs)

Details

Attachments

(1 file)

The initial implementation automatically searches for self's key based on the email address. This is used for openpgp signing, for encrypting to self, and for attaching self's public key.

This needs to be changed to use the configured openpgp key, as introduced in bug 1603809.

As part of this bug I'm also changing the key generation code, to set the new preference for the key id, and no longer the old preference that enigmail used.

The reason why I'm changing it:

  • enigmail used two separate prefs for "pgp enabled" and "configured pgp key id"
  • I'd like the thunderbird implementation to use a single pref for both, if a key id is configured, that's the signal that the user has opted in to use pgp. (I'd like to set the id as part of key generation wizards, or when importing from a backup.)
  • by using two different prefs, it will simplify preference migration, as we can clearly distinguish the old enigmail pref from the new one

Khushil, Magnus, I'd like to ask for your advice.

I have a dialog for assisted openpgp setup. That setup changes an existing identity pref.

If the corresponding account pref tab is currently open, I need to notify it, so it can update the shown preference value.

What's a good mechanism to implement such a notification, sent from a dialog to the account manager (if it's open)?

Flags: needinfo?(khushil324)
window.dispatchEvent(new CustomEvent("prefchange"));

It will trigger a "prefchange" event and corresponding event listener in the Account Manager Tab will save the preferences.

Flags: needinfo?(khushil324)

(In reply to Khushil Mistry [:khushil324] from comment #3)

window.dispatchEvent(new CustomEvent("prefchange"));

It will trigger a "prefchange" event and corresponding event listener in the Account Manager Tab will save the preferences.

That doesn't seem to do what I need.
I don't need "saving". I need "updating of the visible content shown in an open account manager tab".
I need a broadcasting mechanism from a modal dialog to the account manager window.
Maybe I need to implement that myself, by introducing a new global event, and observe for that event inside account manager.

Blocks: 1621796

We could move the issue from comment 2, 3, 4 to bug 1621796 and handle it in a follow-up step.

Note: I already have the patch for this bug. But I'm not yet uploading it.

The reason is, my work depends on the code from bug 1603809, which is not yet reviewed.

(In reply to Kai Engert (:KaiE:) from comment #4)

That doesn't seem to do what I need.
I don't need "saving". I need "updating of the visible content shown in an open account manager tab".

You should probably just have an eventlistener for "prefchange", and then do what you need to do update the UI.

(In reply to Magnus Melin [:mkmelin] from comment #7)

You should probably just have an eventlistener for "prefchange", and then do what you need to do update the UI.

I haven't succeeded in catching the event.
I tried to add
document.addEventListener("prefchange", onPrefchange);
in the account manager pane, but onPrefchange isn't reached.

In mailnews/base/prefs/content/AccountManager.js there's also an event listener for "prefchange", but that seems to be never reached? I added a console.debug that's never reached when changing prefs and switching account manager tabs.

It's not obvious to me how to listen for that event.

I'll attach a patch for review by Patrick, with the following changes:

  • use the configured key id when attaching a public key to outgoing mail
    and when encrypting to self (no longer search by email address)

Drive-by changes:

  • automatically save a revocation certificate when creating a new key
  • we ran through PGP init multiple times, fixed that to run only once
  • keyring key listing now excludes expired keys
    (if necessary, I'll parameterize that later)
  • renamed some parameters to make it clear they are of array type
  • remove old enigmail prefs for key id and enabled mode
  • removed some code we no longer need

Pushed by kaie@kuix.de:
https://hg.mozilla.org/comm-central/rev/b0232faeed8a
Change OpenPGP to use the configured key. r=PatrickBrunschwig

Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → Thunderbird 76.0
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: