jstedfast / MimeKit

A .NET MIME creation and parser library with support for S/MIME, PGP, DKIM, TNEF and Unix mbox spools.
http://www.mimekit.net
MIT License
1.79k stars 360 forks source link

The PGP key server query builder omits leading zero(s) in 'keyId' parameter #1028

Closed khakim0v closed 2 months ago

khakim0v commented 2 months ago

Describe the bug It appears that there is an issue with a PGP key server query building. The current format for constructing the request leads to leading zero(s) (if present) of 'keyid' being omitted. Which in turn causes an "Invalid request/Not found" error on a key server. Tested on keys.openpgp.org, keyserver.ubuntu.com and pgp.mit.edu.

Examples: https://keys.openpgp.org/pks/lookup?op=get&options=mr&search=0x04376F3EE0856959 (valid) https://keys.openpgp.org/pks/lookup?op=get&options=mr&search=0x4376F3EE0856959 (error)

Platform:

Expected behavior The format string in code should be updated to "op=get&search=0x{0:X16}" to correctly represent keyId as a fixed-width string of 16 hex digits: https://github.com/jstedfast/MimeKit/blob/f3db67a73ec3dae89aee7105e9af94a412078b98/MimeKit/Cryptography/OpenPgpContext.cs#L664

jstedfast commented 2 months ago

Released 4.6.0 with this fix