Skip to content

carddav: fix contact encryption key selection (user key vs address key)#327

Open
haurucknde wants to merge 1 commit intoemersion:masterfrom
haurucknde:fix/hydroxide-carddav-user-key
Open

carddav: fix contact encryption key selection (user key vs address key)#327
haurucknde wants to merge 1 commit intoemersion:masterfrom
haurucknde:fix/hydroxide-carddav-user-key

Conversation

@haurucknde
Copy link

Problem

CardDAV contact creation/updates fail with openpgp: incorrect key or produce contacts
that show "The decryption of the encrypted content failed" in Proton's web UI.

Fixes #157, fixes #288.

Root Cause

Unlock() returned only address keys in the key ring. However, Proton's web client
encrypts and signs contacts using the user key (the master account key), not the
address key. On accounts where the user key and address key differ — which is the case
for all modern Proton accounts — contacts written by hydroxide cannot be decrypted by
the Proton client.

Fix

  • Unlock() now includes user keys in the returned key ring (user keys first, then
    address keys), and tracks the primary user key ID separately.
  • The CardDAV handler encrypts and signs contact data using the primary user key,
    matching the behaviour of Proton's own clients.

Testing

Verified on a modern Proton account (separate user key and address key):

  • PUT a vCard with FN, EMAIL, NOTE, CATEGORIES → HTTP 201
  • Contact opens in Proton web UI without any decryption warning
  • All fields (including encrypted detail fields) render correctly
  • CalDAV (IMAP/SMTP) continues to work normally after this change

Unlock() returned only address keys in the key ring. However, Proton's
web client encrypts and signs contacts using the user key (the master
account key), not the address key. On accounts where the user key and
address key differ — which is the case for all modern Proton accounts —
contacts written via CardDAV cannot be decrypted by the Proton client,
resulting in "The decryption of the encrypted content failed" errors.

Fixes emersion#157
Fixes emersion#288

Unlock() now includes user keys in the returned key ring (user keys
first, then address keys) and tracks the primary user key ID separately.
The CardDAV handler encrypts and signs contact data using the primary
user key, matching the behaviour of Proton's own clients.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

carddav not working CardDAV access returns 500 "openpgp: incorrect key"

1 participant