diff --git a/README.md b/README.md index c7f6dd1..e9a7e43 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ For installation instructions, please refer to the included INSTALL file. - gpg-mailgate-web extension is a web interface allowing any user to upload PGP keys so that emails sent to them from your mail server will be encrypted (see gpg-mailgate-web directory for details) - people can submit their public key like to any keyserver to gpg-mailgate with the gpg-mailgate-web extension - people can send an S/MIME signed email to register@yourdomain.tld to register their public key -- people can send their public OpenPGP key as attachment to register@yourdomain.tld to register it +- people can send their public OpenPGP key as attachment or inline to register@yourdomain.tld to register it This is forked from the original project at http://code.google.com/p/gpg-mailgate/ @@ -30,10 +30,12 @@ This is a combined work of many developers and contributor:s * Bruce Markey - [GitHub](https://github.com/TheEd1tor) * Remko Tronçon - [GitHub](https://github.com/remko/phkp/) * Kiritan Flux [GitHub](https://github.com/kflux) +* Fabian Krone [GitHub] (https://github.com/fkrone/gpg-mailgate) # To Do * clean up code -* add optional email registration with attached public key to register@domain.tld done -* outsource templates for emails and mailgate-web +* rewrite templates for register-handler +* rewrite and improve installation instructions * rename from gpg-mailgate to openpgp-s-mime-mailgate or something..... +* even more magical stuff diff --git a/register-handler.py b/register-handler.py index 281a42b..e9da7b5 100644 --- a/register-handler.py +++ b/register-handler.py @@ -42,12 +42,19 @@ if __name__ == "__main__": sign_part = None for msg_part in register_msg.walk(): if msg_part.get_content_type().lower() == "application/pkcs7-signature" or msg_part.get_content_type().lower() == "application/x-pkcs7-signature": - sign_type = 'smime'; + sign_type = 'smime' sign_part = msg_part break elif msg_part.get_content_type().lower() == "application/pgp-keys": - sign_type = 'pgp'; - sign_part = msg_part + sign_type = 'pgp' + sign_part = msg_part.get_payload() + break + elif "-----BEGIN PGP PUBLIC KEY BLOCK-----" in msg_part.get_payload() and "-----END PGP PUBLIC KEY BLOCK-----" in msg_part.get_payload(): + msg_content = msg_part.get_payload() + start = msg_content.find("-----BEGIN PGP PUBLIC KEY BLOCK-----") + end = msg_content.find("-----END PGP PUBLIC KEY BLOCK-----") + sign_type = 'pgp' + sign_part = msg_content[start:end + 34] break if sign_part == None: @@ -89,7 +96,7 @@ if __name__ == "__main__": elif sign_type == 'pgp': # send POST to localost on port 11371 which points to our HTTP registration page - sig = sign_part.get_payload() + sig = sign_part payload = {'email': from_addr, 'key': sig} r = requests.post("http://127.0.0.1:11371", data=payload)