Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PGP support for emails #414

Closed
Redsandro opened this issue Jul 31, 2021 · 7 comments
Closed

PGP support for emails #414

Redsandro opened this issue Jul 31, 2021 · 7 comments

Comments

@Redsandro
Copy link

Redsandro commented Jul 31, 2021

💡 The Idea

Allow to encrypt messages and attachments with PGP/GnuPG using a specified public key before sending emails.

This way you can forward sensitive content to your self-hosted apprise where it will be encrypted before being sent to a publicly hosted mail server over which you don't have control.

👨‍💻 The Implementation

I don't know how to do this platform independently in Python. A search provided some possibly interesting related projects:

  • gnupg- a wrapper around the GnuPG executable.
  • python-gnupg- another wrapper around the GnuPG executable.
  • gpgkeys- another wrapper around the GnuPG executable.
  • gpglib- a pure python library for parsing OpenPGP packets and decrypting messages.
  • OpenPGP- an unmaintained pure python library with much of the functionality of old versions of GnuPG.
  • OpenPGP-Python- a pure python port of openpgp-php. It can parse OpenPGP packets and verify & create signatures.

Perhaps it's easiest to do a switch internally and call os dependent binaries. Throw an error when binary does not exist.

@caronc
Copy link
Owner

caronc commented Jul 31, 2021

The only problem i see with PGP is that the certificate can bet quite large. The only way I can think of implementing this is adding ?pgp=/path/to/local/key in the URL:

  • mailtos://user:pass@hostname/mybuddy@gmail.com?pgp=/home/.pgp/key

Or it could be ?sign= or whatever you feel is more appropriate.

The only catch is that his feature wouldn't work using say the Apprise API for example because it could possibly be exploited (accessing someones remote server and passing in different local files to ?pgp=. You know?

Thoughts?

@Redsandro
Copy link
Author

I think you should think of the certificate as a file rather than a string:

apprise --title 'Sensitive content' \
        --body 'Here is the leaked document.' \
        --attach document.pdf \
        --pgp certificate.key \
        'mailto://myemail:mypass@protonmail.com'

if a --pgp file is supplied, it needs to be used in email related plugins. I.e. if the certificate is wrong, invalid, or path does not exist etc throw an error so the email is not sent unencrypted by mistake.

@caronc
Copy link
Owner

caronc commented Oct 4, 2024

See Pull Request in link above for details, but Email Support now fully supports PGP Encryption.

@caronc caronc closed this as completed Oct 4, 2024
@ZzenlD
Copy link

ZzenlD commented Oct 28, 2024

Does the PGP support also support signing (without encryption) of emails and dynamic recognition and encryption via WKD?
I have not found anything about this in the pull request. If this is possible, how do I integrate the private key?

@caronc
Copy link
Owner

caronc commented Oct 28, 2024

No WKD support, no. That would be extra work, but doable. You need to just export your public key so that it's accessible in Apprise. Apprise knows which key to use based on the sender's email being a part of the filename you place for it (with -pub.asc suffix); see PR.

Private key is only required for decryption where as the Public key is used for encryption. Apprise only sends, so it only needs the encryption element at this time.

Edit: are you looking for a situation where you selectively do not want to encrypt some emails, but encrypt others carrying the same payload?

@ZzenlD
Copy link

ZzenlD commented Oct 28, 2024

Hello, thanks for the answer.

No, I myself use Mailrise as an SMTP relay and would like all emails sent by Apprise to be signed and sent to the recipients.

I have already stored the public key for the sender with the email provider so that the recipients can check the signature via WKD. Now Apprise only has to sign the mails with a stored private key.

Ideally, Apprise would check for each recipient email whether a public key for encryption is available via WKD and then use this as well.

With this setup, outgoing emails would then always be signed and, if a public key is available, additionally encrypted. This would increase security considerably.

@ZzenlD
Copy link

ZzenlD commented Oct 29, 2024

Is it understandable what I want to achieve, or is it perhaps already possible and I have just overlooked it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants