KMail/Protected Headers

From KDE UserBase Wiki
Revision as of 22:39, 11 June 2020 by Hefee (talk | contribs) (Add Protected header page for KMail)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Kmail support Protected Headers for Cryptographic E-Mails. This means that we also send a signed/encrypted copy of headers and display the signed/encrypted headers if available and ignores the unsecure headers. Currently KMail don’t obfuscate the subject to not break current workflows. Those things will be improved later on.

It is transparent for users and no difference is shown for an user, but this feature is only enabled for Grantlee based header themes.

Developers information

If developers want to dig into encrypted headers, there are two places to look for the code. For sending it is the class MessageComposer::ProtectedHeadersJob: messagecomposer/src/job/protectedheaders.h

usage:

  • KMime::Content *content - mime part that will be encrypted/signed
  • KMime::Message *skeletonMessage - message the has all the headers, that will ent unencrypted over the wire. The headers from this will be copied to `content`
  • bool protectedHeadersObvoscate - obfuscated the subject or not


ProtectedHeadersJob *pJob = new ProtectedHeadersJob;
pJob->setContent(content);
pJob->setSkeletonMessage(skeletonMessage);
pJob->setObvoscate(protectedHeadersObvoscate);
QObject::connect(pJob, &ProtectedHeadersJob::finished, this, [d, pJob](KJob *job) {...});

For displaying the protected headers, first the mail needs to get parsed within the MimeTreeParser. If the correct structure is used than the encrypted MimePart is added registered to override and unencrypted header. After that you can use MimeTreeParser::NodeHelper::hasMailHeader and other methods to ask the system to give you the correct header for and mail. This is done for Grantlee based header themes.