From 36211267bf03bb3cf542d0ce49497ad8927b77d7 Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Fri, 25 Aug 2017 16:07:09 +0200 Subject: [PATCH] S/MIME: - Implement unknownemail status in case signer email address is not matched with sender email address --- api/src/Mail.php | 13 ++++++++++++- mail/js/app.js | 13 +++++++++---- mail/templates/default/app.css | 19 +++++++++++++------ mail/templates/mobile/app.css | 18 ++++++++++++------ mail/templates/pixelegg/app.css | 18 ++++++++++++------ 5 files changed, 58 insertions(+), 23 deletions(-) diff --git a/api/src/Mail.php b/api/src/Mail.php index caae17bf99..75b984dc28 100644 --- a/api/src/Mail.php +++ b/api/src/Mail.php @@ -7381,15 +7381,26 @@ class Mail if ($cert) // signed message, it might be encrypted too { + $envelope = $this->getMessageEnvelope($params['uid'], '', false, $params['mailbox']); + $from = $this->stripRFC822Addresses($envelope['FROM']); $message_parts = $this->smime->extractSignedContents($message); + //$f = $message_parts->_headers->getHeader('from'); $metadata = array_merge ($metadata, array ( 'verify' => $cert->verify, 'cert' => $cert->cert, 'msg' => $cert->msg, 'certHtml' => $this->smime->certToHTML($cert->cert), 'email' => $cert->email, - 'signed' => true, + 'signed' => true )); + // check for email address if both signer email address and + // email address of sender are the same. + if (is_array($from) && $from[0] != $cert->email) + { + $metadata['unknownemail'] = true; + $metadata['msg'] .= ' '.lang('Email address of signer is different from the email address of sender!'); + } + $AB_bo = new \addressbook_bo(); $certkey = $AB_bo->get_smime_keys($cert->email); if (!is_array($certkey) || $certkey[$cert->email] != $cert->cert) $metadata['addtocontact'] = true; diff --git a/mail/js/app.js b/mail/js/app.js index 2803014050..3544f122d4 100644 --- a/mail/js/app.js +++ b/mail/js/app.js @@ -5837,21 +5837,26 @@ app.classes.mail = AppJS.extend( else if (data.verify) { $mail_container.addClass((data.class='smime_cert_verified')); - smime_signature.set_class('smime_cert_verified'); + smime_signature.set_class(data.class); smime_signature.set_statustext(data.msg); } else if (!data.verify && data.cert) { $mail_container.addClass((data.class='smime_cert_notverified')); - smime_signature.set_class('smime_cert_notverified'); + smime_signature.set_class(data.class); smime_signature.set_statustext(data.msg); } else if (!data.verify && !data.cert) { $mail_container.addClass((data.class='smime_cert_notvalid')); - smime_signature.set_class('smime_cert_notvalid'); + smime_signature.set_class(data.class); smime_signature.set_statustext(data.msg); } + if (data.unknownemail) + { + $mail_container.addClass((data.class='smime_cert_unknownemail')); + smime_signature.set_class(data.class); + } jQuery(smime_signature.getDOMNode(), smime_encryption.getDOMNode()).on('click',function(){ self.smime_certAddToContact(data,true); }); @@ -5869,7 +5874,7 @@ app.classes.mail = AppJS.extend( { for(var i=0;i<_nodes.length;i++) { - var smime_classes = 'smime_cert_verified smime_cert_notverified smime_cert_notvalid'; + var smime_classes = 'smime_cert_verified smime_cert_notverified smime_cert_notvalid smime_cert_unknownemail'; _nodes[i].removeClass(smime_classes); _nodes[i].off('click'); } diff --git a/mail/templates/default/app.css b/mail/templates/default/app.css index f87113ea10..31ea763f37 100644 --- a/mail/templates/default/app.css +++ b/mail/templates/default/app.css @@ -914,20 +914,27 @@ div.mailComposeHeaderSection>table { .header_row_right.vertical_splitter div#mail-index_mail-index-vacationnotice .et2_vbox {margin-right: 0;} div.smime_cert_notverified { - border-top: 4px solid lightgreen !important; + border-top: 4px solid #8dff95 !important; } img.smime_cert_notverified { - background: lightgreen; + background: #8dff95; } div.smime_cert_verified { - border-top: 4px solid green !important; + border-top: 4px solid #1ab82c !important; } +div.smime_cert_unknownemail { + border-top: 4px solid #a28cff !important; +} + img.smime_cert_verified { - background: green; + background: #1ab82c; } div.smime_cert_notvalid { - border-top: 4px solid red !important; + border-top: 4px solid #e90052 !important; } img.smime_cert_notvalid { - background: red; + background: #e90052; +} +img.smime_cert_unknownemail { + background: #a28cff; } \ No newline at end of file diff --git a/mail/templates/mobile/app.css b/mail/templates/mobile/app.css index d9324da188..70502bc018 100644 --- a/mail/templates/mobile/app.css +++ b/mail/templates/mobile/app.css @@ -902,22 +902,28 @@ div.mailComposeHeaderSection > table { margin-right: 0; } div.smime_cert_notverified { - border-top: 4px solid lightgreen !important; + border-top: 4px solid #8dff95 !important; } img.smime_cert_notverified { - background: lightgreen; + background: #8dff95; } div.smime_cert_verified { - border-top: 4px solid green !important; + border-top: 4px solid #1ab82c !important; +} +div.smime_cert_unknownemail { + border-top: 4px solid #a28cff !important; } img.smime_cert_verified { - background: green; + background: #1ab82c; } div.smime_cert_notvalid { - border-top: 4px solid red !important; + border-top: 4px solid #e90052 !important; } img.smime_cert_notvalid { - background: red; + background: #e90052; +} +img.smime_cert_unknownemail { + background: #a28cff; } #popupMainDiv { padding: 5px; diff --git a/mail/templates/pixelegg/app.css b/mail/templates/pixelegg/app.css index bc4252592c..d7dac62d76 100755 --- a/mail/templates/pixelegg/app.css +++ b/mail/templates/pixelegg/app.css @@ -890,22 +890,28 @@ div.mailComposeHeaderSection > table { margin-right: 0; } div.smime_cert_notverified { - border-top: 4px solid lightgreen !important; + border-top: 4px solid #8dff95 !important; } img.smime_cert_notverified { - background: lightgreen; + background: #8dff95; } div.smime_cert_verified { - border-top: 4px solid green !important; + border-top: 4px solid #1ab82c !important; +} +div.smime_cert_unknownemail { + border-top: 4px solid #a28cff !important; } img.smime_cert_verified { - background: green; + background: #1ab82c; } div.smime_cert_notvalid { - border-top: 4px solid red !important; + border-top: 4px solid #e90052 !important; } img.smime_cert_notvalid { - background: red; + background: #e90052; +} +img.smime_cert_unknownemail { + background: #a28cff; } #popupMainDiv { padding: 5px;