aerc crashes when displaying an email encrypted for someone else's key

A friend of mine just sent me an email and trying to display it caused aerc to crash with the stack trace below. It wasn't until I tried to open it on mobile that I realised exactly why; OpenKeychain said K-9 was requested my friend's key, not mine.

❯ aerc
panic: pgpmail: failed to read PGP message: openpgp: incorrect key

goroutine 1 [running]:
git.sr.ht/~sircmpwn/aerc/lib.NewMessageStoreView.func1(0x55a74e0727a0, 0xc000494f60)
        /home/amolith/repos/aerc/lib/messageview.go:71 +0x2c9
git.sr.ht/~sircmpwn/aerc/lib.(*MessageStore).Update(0xc0000ac3c0, 0x55a74e07e6a0, 0xc0004ae8c0)
        /home/amolith/repos/aerc/lib/msgstore.go:236 +0xa6a
git.sr.ht/~sircmpwn/aerc/widgets.(*AccountView).onMessage(0xc00020b570, 0x55a74e07e6a0, 0xc0004ae8c0)
        /home/amolith/repos/aerc/widgets/account.go:265 +0x4ff
git.sr.ht/~sircmpwn/aerc/widgets.(*AccountView).Tick(0xc00020b570, 0xc000210e00)
        /home/amolith/repos/aerc/widgets/account.go:104 +0xa3
git.sr.ht/~sircmpwn/aerc/widgets.(*Aerc).Tick(0xc00012c4d0, 0xc000296100)
        /home/amolith/repos/aerc/widgets/aerc.go:128 +0x93
        /home/amolith/repos/aerc/aerc.go:185 +0x630
Assigned to
10 months ago
7 months ago
No labels applied.

~reedwade 8 months ago

Got a similar case

goroutine 1 [running]:
	/media/reed/data2/home/reed/workspace/aerc/lib/messageview.go:73 +0x2f0
git.sr.ht/~sircmpwn/aerc/lib.(*MessageStore).Update(0xc00073c280, 0xaf8d00, 0xc0001dc960)
	/media/reed/data2/home/reed/workspace/aerc/lib/msgstore.go:236 +0xa54
git.sr.ht/~sircmpwn/aerc/widgets.(*AccountView).onMessage(0xc0002ee5b0, 0xaf8d00, 0xc0001dc960)
	/media/reed/data2/home/reed/workspace/aerc/widgets/account.go:269 +0x4fd
git.sr.ht/~sircmpwn/aerc/widgets.(*AccountView).Tick(0xc0002ee5b0, 0xc000289800)
	/media/reed/data2/home/reed/workspace/aerc/widgets/account.go:104 +0xa1
git.sr.ht/~sircmpwn/aerc/widgets.(*Aerc).Tick(0xc0002a0160, 0xc0001de000)
	/media/reed/data2/home/reed/workspace/aerc/widgets/aerc.go:134 +0x91
	/media/reed/data2/home/reed/workspace/aerc/aerc.go:185 +0x62e

It seems there are some works with openpgp in aerc but I can't find any config or anything. How should we use it ?

Alex Schroeder 7 months ago · edit

I just got the same error. aerc crashes with "pgpmail: failed to read PGP message: openpgp: incorrect key". When I :pipe gpg -d however, the message gets decrypted correctly. It's a message that is encrypted to both my and the sender. At the top it tells me:

gpg: encrypted with 4096-bit RSA key, ID ... gpg: encrypted with 3072-bit ELG key, ID DE6718E639D2D11F, created 2019-01-20 "Alex Schroeder alex@gnu.org" Content-Type: text/plain; charset=us-ascii Content-Disposition: inline


When I search for either ID using gpg --list-key I get shown the correct keys. In short, there is no reason to believe (at least in my case) that there is an incorrect key being used. Rather, there must be some other incompatibility. This is why I'm appending the output of gpg --version.

Perhaps that will help us find the problem.

Cheers Alex

gpg --version gpg (GnuPG) 2.2.12 libgcrypt 1.8.4 Copyright (C) 2018 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later < https://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.

Home: /home/alex/.gnupg Supported algorithms: Pubkey: RSA, ELG, DSA, ECDH, ECDSA, EDDSA Cipher: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH, CAMELLIA128, CAMELLIA192, CAMELLIA256 Hash: SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224 Compression: Uncompressed, ZIP, ZLIB, BZIP2

~labrat 7 months ago

Aerc doesn't use the keyring of gpg. Hence all your gpg queries are pointless.

You need to manage two different keyrings, gpg and aerc's

Alex Schroeder 7 months ago · edit

On Wed Jun 10, 2020 at 11:52 PM CEST, ~labrat wrote:

You need to manage two different keyrings, gpg and aerc's

Let's rename the bug then: "Document how to read and write encrypted mail using aerc".

~labrat 7 months ago

That bug exists, there are several open tickets tagged with pgp or somesuch

~jamesponddotco 7 months ago

This is what I used to get encryption working, if it helps anyone:

gpg --export >> ~/.local/share/aerc/keyring.asc
gpg --export-secret-keys >> ~/.local/share/aerc/keyring.asc

However, as far as I know, aerc only supports signature verification, and message decryption right now, it does not support message encryption. Plus, you know, with the command above you are exporting your keys, and keeping them somewhere else, so keep that in mind.

Personally, I would recommend waiting until support is complete ⁠— which Drew said[1] is planned, and a blocker for 1.0 —, or piping the message to GPG.

[1] https://news.ycombinator.com/item?id=20091091

Register here or Log in to comment, or comment via email.