C3S / redmine_openpgp

Redmine plugin for email encryption with the OpenPGP standard
GNU General Public License v3.0
19 stars 10 forks source link

using opempgp with imap #21

Open alexhell opened 7 years ago

alexhell commented 7 years ago

Hello,

I installed this plugin and if I fetch my email via rdm-handler, it works fine.

But when I change to imap, the encrypted emails are not decrypted anymore.

Unfortunately it is the only option which the helpdesk-plugin from redmineUP offers.

how I can adjust my redmine server, that I can use your plugin via imap?

cowrycoin commented 6 years ago

Ok, as I see, imap is not the only option in this helpdesk-plugin

And this plugin use it's own email-handler.

timegrid commented 6 years ago

The plugin just extends the email handler of redmine, but probably on a wrong spot for the imap rake task. I'll take a look into it, maybe a fix is easy.

timegrid commented 6 years ago

I don't see right now, why imap should not work - the imap rake task should use the same code as the rdm_mailhandler. Either I got the calls below wrong, the plugin is not included during the rake task, or fails silently. Anything in the logs?

I don't have a test setup for imap, so it probably won't fix soon. If someone wants to take a look, this is what should happen:

With rdm_handler (working):

  1. Mail is piped into RedmineMailHandler (extra/mail_handler/rdm-mailhandler.rb)
  2. RedmineMailHandler posts the validated mail via http into the redmine handler view (app/views/mail_handler/new.html.erb)
  3. The controller of the view MailHandlerController (app/controllers/mail_handler_controller.rb) calls MailHandler.receive()
  4. The class method self.receive() in MailHandler (app/models/mail_handler.rb) calls the instance method new.receive()
  5. The instance method receive() in MailHandler is intercepted by the plugin
  6. receive_with_encryption() (plugins/openpgp/lib/decrypt_mails.rb) decrypts the mail and calls receive_without_encryption()
  7. receive_without_encryption() calls the instance method receive() in MailHandler again and normal processing is resumed

With imap:

  1. The rake task 'receive_imap' (lib/tasks/email.rake) calls Redmine::IMAP.check() (lib/redmine/imap.rb)
  2. Redmine::IMAP.check() calls MailHandler.safe_receive() (app/models/mail_handler.rb)
  3. MailHandler.safe_receive() calls the class method receive()
  4. Same processing as 4. - 7. above
alexhell commented 6 years ago

Ok, it is not a bug.

As I found out that the helpdesk use its own mailer. I changed in init.rb of this plugin

Now imap is working and I can decrypt incoming emails.

And I add in plugins/redmine_contacts_helpdesk/app/models/helpdesk_mailer.rb include EncryptMails include DecryptMails

Where I am still hanging is:

The helpdesk use not the standard user, it use for helpdesk its own "contact". Such a contact has nor a pgp field neither the plugin is searching there for it.

I can add a custom field 'public key' to contacts, but how can I make the pgp plugin using this field for encryption?