Mail: fix S/MIME can not find certificates if certificate emails not written in lowercase

This commit is contained in:
Hadi Nategh 2019-03-13 16:07:34 +01:00
parent 5f3844af14
commit 45bfeed444

View File

@ -7547,6 +7547,7 @@ class Mail
$envelope = $this->getMessageEnvelope($params['uid'], '', false, $params['mailbox']); $envelope = $this->getMessageEnvelope($params['uid'], '', false, $params['mailbox']);
$from = $this->stripRFC822Addresses($envelope['FROM']); $from = $this->stripRFC822Addresses($envelope['FROM']);
$message_parts = $this->smime->extractSignedContents($message); $message_parts = $this->smime->extractSignedContents($message);
$cert_email = strtolower($cert->email);
//$f = $message_parts->_headers->getHeader('from'); //$f = $message_parts->_headers->getHeader('from');
$metadata = array_merge ($metadata, array ( $metadata = array_merge ($metadata, array (
'verify' => $cert->verify, 'verify' => $cert->verify,
@ -7554,12 +7555,12 @@ class Mail
'certDetails' => $this->smime->parseCert($cert->cert), 'certDetails' => $this->smime->parseCert($cert->cert),
'msg' => $cert->msg, 'msg' => $cert->msg,
'certHtml' => $this->smime->certToHTML($cert->cert), 'certHtml' => $this->smime->certToHTML($cert->cert),
'email' => $cert->email, 'email' => $cert_email,
'signed' => true 'signed' => true
)); ));
// check for email address if both signer email address and // check for email address if both signer email address and
// email address of sender are the same. It also takes subjectAltName emails into account. // email address of sender are the same. It also takes subjectAltName emails into account.
if (is_array($from) && strcasecmp($from[0], $cert->email) != 0 if (is_array($from) && strcasecmp($from[0], $cert_email) != 0
&& stripos($metadata['certDetails']['extensions']['subjectAltName'],$from[0]) === false) && stripos($metadata['certDetails']['extensions']['subjectAltName'],$from[0]) === false)
{ {
$metadata['unknownemail'] = true; $metadata['unknownemail'] = true;
@ -7567,8 +7568,8 @@ class Mail
} }
$AB_bo = new \addressbook_bo(); $AB_bo = new \addressbook_bo();
$certkey = $AB_bo->get_smime_keys($cert->email); $certkey = $AB_bo->get_smime_keys($cert_email);
if (!is_array($certkey) || strcasecmp(trim($certkey[$cert->email]), trim($cert->cert)) != 0) $metadata['addtocontact'] = true; if (!is_array($certkey) || strcasecmp(trim($certkey[$cert_email]), trim($cert->cert)) != 0) $metadata['addtocontact'] = true;
} }
else // only encrypted message else // only encrypted message
{ {