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

Support for PGP Email Support (DeltaChat Compatible) #1205

Merged
merged 5 commits into from
Oct 4, 2024
Merged

Conversation

caronc
Copy link
Owner

@caronc caronc commented Sep 17, 2024

Description:

Related issue (if applicable): #414 and #514

Emails to enable Pretty Good Privacy (PGP) support if ?pgp=yes in the email:// Apprise URL.

It's important to note that Apprise ONLY uses the Public (PGP) key which is required for encrypting the messages.

Parameter Breakdown

Variable Required Description
pgp No Optionally enable PGP mode which will automatically generate a public and private key if they aren't otherwise detected.
pgpkey No Provide a path to a PGP Public Key you've already generated. Apprise supports this to be a local path, but you can also specify a web location as well (if you wish to fetch the public key remotely and sign with that).

Utilizes Persistent Storage path associaed with the URL. A PGP Public/Private key is generated automatically if one is not found and the pgpkey isn't specified. The files scanned are (in this sequence and scan stops on first match file):

  1. /persistent/path/url_id/{to-email}-pub.asc
    • For example, if the To Email configured with your mailto:// was [email protected] the file checked is: /persistent/path/url_id/[email protected] (note it is in lowercase)
    • If you identified more then one To Address will repeat this check for each address specified. This allows you to hold on to more then one Public key belonging to an end point.
  2. /persistent/path/url_id/'{email-id}-pub.asc
    • For example, if the To Email configured with your mailto:// was [email protected] the file checked is: /persistent/path/url_id/bob-pub.asc (note it is in lowercase)
    • If you identified more then one To Address will repeat this check for each address specified. This allows you to hold on to more then one Public key belonging to an end point.
  3. /persistent/path/url_id/{from-email}-pub.asc
  4. /persistent/path/url_id/'{email-id}-pub.asc
    • For example, if the From Email configured with your mailto:// was [email protected] the file checked is: /persistent/path/url_id/chucknorris-pub.asc (note it is in lowercase)
  5. /persistent/path/url_id/pgp-public.asc
  6. /persistent/path/url_id/pgp-pub.asc
  7. /persistent/path/url_id/public.asc
  8. /persistent/path/url_id/pub.asc

Pretty Good Privacy Key Generation

If the entire list above is scanned and no PGP file was found, a key will be generated as /persistent/path/url_id/pgp-public.asc

DeltaChat Support

DeltaChat is fully supported now using the new PGP setup. To leverage an encrypted chat:

  1. Access the Settings
  2. Click on Advanced
  3. Click on Managed Keys
  4. Choose Export Secret Keys
    • You only need the public key; copy it into you /persistent/path/url_id/ in one of the expected formats.

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • No lint errors (use flake8)
  • 100% test coverage

Testing

Anyone can help test this source code as follows:

# Create a virtual environment to work in as follows:
python3 -m venv apprise

# Change into our new directory
cd apprise

# Activate our virtual environment
source bin/activate

# Install the branch
pip install git+https://github.com/caronc/apprise.git@414-pgp-support

# You will need to have PGPy package installed:
pip install PGPy

# Test out the changes with the following command; the below would look in the local persistent
# Cache locations
apprise -t "Test Title" -b "Test Message" \
 "mailto://credentials?pgp=yes"

# Fetch a public PGP key from a location on the web
apprise -t "Test Title" -b "Test Message" \
 "mailto://credentials?pgp=yes&pgpkey=https://user:pass@host/path/to/remote/public/pgp-pub.key.asc"

# Fetch a public PGP key from a local location via a local file path
apprise -t "Test Title" -b "Test Message" \
 "mailto://credentials?pgp=yes&pgpkey=/path/to/file"

Copy link

codecov bot commented Sep 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.36%. Comparing base (f35145e) to head (800aad7).
Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff            @@
##           master    #1205    +/-   ##
========================================
  Coverage   99.35%   99.36%            
========================================
  Files         148      148            
  Lines       20438    20682   +244     
  Branches     3997     4042    +45     
========================================
+ Hits        20307    20551   +244     
  Misses        121      121            
  Partials       10       10            

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@caronc caronc changed the title Support for PGP Email Support Support for PGP Email Support (DeltaChat Compatible) Oct 4, 2024
@caronc caronc merged commit f656069 into master Oct 4, 2024
14 checks passed
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.

1 participant