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

Enigma smime signed messages verification #6043

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

duk3luk3
Copy link
Contributor

This is the first step to address #4977.

I made this PR to familiarise myself with the enigma plugin and show a first proof-of-concept.

Description

It does the following things:

  • Hooks up SMIME signature verification logic that already mostly existed in enigma
  • Allows the server administrator to specify trusted CA files in enigma plugin config
  • Introduces new "server-verified" verification level: If trusted CAs are specified in enigma plugin config, full verification trust (Green bar) is reserved for messages signed with a certificate trusted by one of those CAs; messages signed by a certificate trusted by the default CAs are displayed as "server-verified" with a yellow bar.

What it doesn't do:

  • No decryption - so also no verification of encrypted messages
  • No encryption
  • No user CAs / certificates

What I am finding out here is that the php openssl module is severely limited in what it can do. Things I would like to do but seemingly can't using php openssl:

  • Use intermediate certificates as trust anchors
  • Retrieve the whole certificate chain used to verify a signature

It may be necessary to invoke an openssl executable directly to actually implement all the features users would expect.

How to test

Test basic verification:

  • Enable the enigma plugin using the code in this branch
  • Open a signed (unencrypted!) S/MIME message
  • If the root ca for the signature of that message is in your server's cert store, you should see a green signature verification bar

Test verification of configured CAs:

  • Set $config['enigma_smime_ca'] = array('/'); (a directory without certificates)
  • The message should now have a yellow signature verification bar
  • Set $config['enigma_smime_ca'] = array('/path/to/ca.cert'); referencing the correct root ca
  • The message should now have a green bar again

@taalas
Copy link

taalas commented Nov 14, 2017

Looks very promising. Looking forward to this being merged.

@alecpl
Copy link
Member

alecpl commented Nov 20, 2017

Looks good. I'm not sure it should be merged with master. Maybe a separate branch would be better. Or we implement an option that will disable the whole S/MIME functionality by default.

@duk3luk3
Copy link
Contributor Author

duk3luk3 commented Nov 22, 2017

The S/MIME functionality (as it is implemented so far) is completely unobtrusive.

Once I add more UI for it (e.g. Certificate Management and a column to enable/disable S/MIME functions in the main Enigma config panel), the existing config override system can be used to disable S/MIME entirely and it's fine to set it disabled by default.

Is that agreeable?

@renne
Copy link

renne commented Feb 8, 2018

Does it support retrieving S/MIME certificates from DNS according to IETF RFC 8162?

@G00sfraba
Copy link

Can you share a screenshot of how this should look?
I've applied the changes from this PR manually on my local copy, but I, can't see this "green bar" you are referring to. Any advice or guidance?

PS, I also tried direct install from the branch, but still with 0 success on any indication for valid s/mime signed email on the UI.

@m-ueberall
Copy link

m-ueberall commented Jun 8, 2019

@G00sfraba It looks as follows after I've applied the (corrected) resulting patch against v1.3.9 today:

image

@tborychowski
Copy link

Any update on this? Would love to see that feature :-)

@G00sfraba
Copy link

Any update on this? Would love to see that feature :-)

I ended up customising rc_smime.php as I need. have to say that no other changes were needed since then (more than an year ago) so go for it.

@tborychowski
Copy link

@G00sfraba, would you have a fork/branch/repo with these changes?
Or could you share them in any way? :-)

@dereks
Copy link

dereks commented Aug 20, 2020

Thank you for submitting a Pull Request (PR) to the Roundcube GitHub project.

You are receiving this message because your PR has conflicts which need to be resolved. We are trying to catch up on our backlog of old PRs and get them merged in (where appropriate). Therefor, we request the following:

Step 1. Rebase from the latest Roundcube branch master into your PR.

git fetch upstream
git checkout your_feature_branch_name
git rebase upstream/master
git push -f origin your_feature_branch_name

Step 2. Re-test to make sure your new code still works as expected

Step 3. Comment back here once it has been tested and will merge cleanly.

Once this has been done we will treat it like a new Pull Request and consider it for acceptance.

Apologies for the inconvenience. Thank you for contributing to Roundcube!

@@ -37,6 +38,7 @@ function __construct($user)
function init()
{
$homedir = $this->rc->config->get('enigma_smime_homedir', INSTALL_PATH . '/plugins/enigma/home');
$this->cainfo = $this->rc->config->get('enigma_smime_ca', array());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're using short array syntax now.

@@ -65,6 +67,15 @@ function init()

$this->homedir = $homedir;

#XXX: Workaround for https://bugs.php.net/bug.php?id=75494
if (count($this->cainfo) > 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be a warning if the option in config is not an array.

if ($sig !== true) {
// try with server trusted certificate verification
$sig = openssl_pkcs7_verify($msg_file, 0, $cert_file);
$validity = enigma_error::SERVER_VERIFIED;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would that be an error? Find another way to pass this info, e.g. involving enigma_signature::$partial.

@@ -229,6 +245,8 @@ private function parse_sig_cert($file, $validity)
// $data->comment = '';
$data->email = $cert['subject']['emailAddress'];

rcube::write_log('errors', 'Decrypted sig: ' . $data->name);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not needed.

@@ -30,6 +30,7 @@ class enigma_error
const BADPASS = 5;
const EXPIRED = 6;
const UNVERIFIED = 7;
const SERVER_VERIFIED = 8;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is conflict that needs to be resolved.

@@ -19,6 +19,8 @@ class enigma_mime_message extends Mail_mime
{
const PGP_SIGNED = 1;
const PGP_ENCRYPTED = 2;
const SMIME_SIGNED = 3;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These new const aren't used/implemented yet. I would remove them.

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.

8 participants