W.I.P. SMIME:

- add notvalid state
- add metadata for key add to contact
This commit is contained in:
Hadi Nategh 2017-07-25 18:00:22 +02:00
parent 91fb816bb2
commit f600436898
5 changed files with 29 additions and 11 deletions

View File

@ -7368,6 +7368,15 @@ class Mail
{ {
throw new Mail\Smime\PassphraseMissing($message['msg']); throw new Mail\Smime\PassphraseMissing($message['msg']);
} }
// verifivation failure either message has been tempered,
// signature is not valid or message has not ben signed
// but encrypted only.
else
{
$metadata['verify'] = false;
$metadata['signed'] = true;
$metadata['msg'] = $ex->getMessage();
}
} }
if ($cert) // signed message, it might be encrypted too if ($cert) // signed message, it might be encrypted too
@ -7380,6 +7389,9 @@ class Mail
'certHtml' => $this->smime->certToHTML($cert->cert), 'certHtml' => $this->smime->certToHTML($cert->cert),
'signed' => true, 'signed' => true,
)); ));
$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;
} }
else // only encrypted message else // only encrypted message
{ {

View File

@ -5832,19 +5832,25 @@ app.classes.mail = AppJS.extend(
$mail_container.addClass('smime_cert_verified'); $mail_container.addClass('smime_cert_verified');
smime_signature.set_class('smime_cert_verified'); smime_signature.set_class('smime_cert_verified');
} }
else if (!_data.verify) else if (!_data.verify && _data.cert)
{ {
$mail_container.addClass('smime_cert_notverified'); $mail_container.addClass('smime_cert_notverified');
smime_signature.set_class('smime_cert_notverified'); smime_signature.set_class('smime_cert_notverified');
smime_signature.set_statustext(_data.msg); smime_signature.set_statustext(_data.msg);
} }
else if (!_data.verify && !_data.cert)
{
$mail_container.addClass('smime_cert_notvalid');
smime_signature.set_class('smime_cert_notvalid');
smime_signature.set_statustext(_data.msg);
}
}, },
smime_clear_flags: function (_nodes) smime_clear_flags: function (_nodes)
{ {
for(var i=0;i<_nodes.length;i++) for(var i=0;i<_nodes.length;i++)
{ {
var smime_classes = 'smime_cert_verified smime_cert_notverified'; var smime_classes = 'smime_cert_verified smime_cert_notverified smime_cert_notvalid';
_nodes[i].removeClass(smime_classes); _nodes[i].removeClass(smime_classes);
} }

View File

@ -917,16 +917,16 @@ div.smime_cert_notverified {
border-top: 4px solid lightgreen !important; border-top: 4px solid lightgreen !important;
} }
img.smime_cert_notverified { img.smime_cert_notverified {
background: lightgreen !important; background: lightgreen;
} }
div.smime_cert_verified { div.smime_cert_verified {
border-top: 4px solid green; border-top: 4px solid green !important;
} }
img.smime_cert_verified { img.smime_cert_verified {
background: green; background: green;
} }
div.smime_cert_notvalid { div.smime_cert_notvalid {
border-top: 4px solid red; border-top: 4px solid red !important;
} }
img.smime_cert_notvalid { img.smime_cert_notvalid {
background: red; background: red;

View File

@ -905,16 +905,16 @@ div.smime_cert_notverified {
border-top: 4px solid lightgreen !important; border-top: 4px solid lightgreen !important;
} }
img.smime_cert_notverified { img.smime_cert_notverified {
background: lightgreen !important; background: lightgreen;
} }
div.smime_cert_verified { div.smime_cert_verified {
border-top: 4px solid green; border-top: 4px solid green !important;
} }
img.smime_cert_verified { img.smime_cert_verified {
background: green; background: green;
} }
div.smime_cert_notvalid { div.smime_cert_notvalid {
border-top: 4px solid red; border-top: 4px solid red !important;
} }
img.smime_cert_notvalid { img.smime_cert_notvalid {
background: red; background: red;

View File

@ -893,16 +893,16 @@ div.smime_cert_notverified {
border-top: 4px solid lightgreen !important; border-top: 4px solid lightgreen !important;
} }
img.smime_cert_notverified { img.smime_cert_notverified {
background: lightgreen !important; background: lightgreen;
} }
div.smime_cert_verified { div.smime_cert_verified {
border-top: 4px solid green; border-top: 4px solid green !important;
} }
img.smime_cert_verified { img.smime_cert_verified {
background: green; background: green;
} }
div.smime_cert_notvalid { div.smime_cert_notvalid {
border-top: 4px solid red; border-top: 4px solid red !important;
} }
img.smime_cert_notvalid { img.smime_cert_notvalid {
background: red; background: red;