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 cbd23c6934
commit 50266fb153

View File

@ -7533,6 +7533,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,
@ -7540,12 +7541,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;
@ -7553,8 +7554,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
{ {