@@ -64,8 +64,7 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | if (version_compare(phpversion(), '5.4', '<')) { |
| 66 | 66 | $this->cipher = OPENSSL_CIPHER_3DES; |
| 67 | - } |
|
| 68 | - else { |
|
| 67 | + } else { |
|
| 69 | 68 | $this->cipher = PLUGIN_SMIME_CIPHER; |
| 70 | 69 | } |
| 71 | 70 | } |
@@ -188,8 +187,7 @@ discard block |
||
| 188 | 187 | |
| 189 | 188 | if (array_filter($missingCerts, "missingMyself") === []) { |
| 190 | 189 | $errorMsg = _('Missing public certificates for the following recipients: ') . implode(', ', $missingCerts) . _('. Please contact your system administrator for details'); |
| 191 | - } |
|
| 192 | - else { |
|
| 190 | + } else { |
|
| 193 | 191 | $errorMsg = _("Your public certificate is not installed. Without this certificate, you will not be able to read encrypted messages you have sent to others."); |
| 194 | 192 | } |
| 195 | 193 | |
@@ -225,8 +223,7 @@ discard block |
||
| 225 | 223 | // Put empty string into file? dafuq? |
| 226 | 224 | file_put_contents($tmpUserCert, $userCert); |
| 227 | 225 | } |
| 228 | - } |
|
| 229 | - catch (MAPIException $e) { |
|
| 226 | + } catch (MAPIException $e) { |
|
| 230 | 227 | $msg = "[smime] Unable to open PR_SENT_REPRESENTING_ENTRYID. Maybe %s was does not exists or deleted from server."; |
| 231 | 228 | Log::write(LOGLEVEL_ERROR, sprintf($msg, $userProps[PR_SENT_REPRESENTING_NAME])); |
| 232 | 229 | error_log("[smime] Unable to open PR_SENT_REPRESENTING_NAME: " . print_r($userProps[PR_SENT_REPRESENTING_NAME], true)); |
@@ -242,8 +239,7 @@ discard block |
||
| 242 | 239 | $senderAddressArray = $senderAddressArray['props']; |
| 243 | 240 | if ($senderAddressArray['address_type'] === 'SMTP') { |
| 244 | 241 | $emailAddr = $senderAddressArray['email_address']; |
| 245 | - } |
|
| 246 | - else { |
|
| 242 | + } else { |
|
| 247 | 243 | $emailAddr = $senderAddressArray['smtp_address']; |
| 248 | 244 | } |
| 249 | 245 | |
@@ -253,8 +249,7 @@ discard block |
||
| 253 | 249 | if (!$emailAddr) { |
| 254 | 250 | if (!empty($userProps[PR_SENT_REPRESENTING_NAME])) { |
| 255 | 251 | $emailAddr = $userProps[PR_SENT_REPRESENTING_NAME]; |
| 256 | - } |
|
| 257 | - else { |
|
| 252 | + } else { |
|
| 258 | 253 | $searchKeys = mapi_getprops($message, [PR_SEARCH_KEY, PR_SENT_REPRESENTING_SEARCH_KEY]); |
| 259 | 254 | $searchKey = $searchKeys[PR_SEARCH_KEY] ?? $searchKeys[PR_SENT_REPRESENTING_SEARCH_KEY]; |
| 260 | 255 | if ($searchKey) { |
@@ -307,16 +302,14 @@ discard block |
||
| 307 | 302 | $importMessageCert !== false) { |
| 308 | 303 | // Redundant |
| 309 | 304 | $importMessageCert = true; |
| 310 | - } |
|
| 311 | - else { |
|
| 305 | + } else { |
|
| 312 | 306 | $importMessageCert = false; |
| 313 | 307 | verifyOCSP($userCert, $caCerts, $this->message); |
| 314 | 308 | break; |
| 315 | 309 | } |
| 316 | 310 | } |
| 317 | 311 | } |
| 318 | - } |
|
| 319 | - else { |
|
| 312 | + } else { |
|
| 320 | 313 | // Works. Just leave it. |
| 321 | 314 | $signed_ok = openssl_pkcs7_verify($tmpfname, PKCS7_NOSIGS, $outcert, explode(';', PLUGIN_SMIME_CACERTS)); |
| 322 | 315 | $openssl_error_code = $this->extract_openssl_error(); |
@@ -333,8 +326,7 @@ discard block |
||
| 333 | 326 | } |
| 334 | 327 | // We don't have a certificate from the MAPI UserStore or LDAP, so we will set $userCert to $importCert |
| 335 | 328 | // so that we can verify the message according to the be imported certificate. |
| 336 | - } |
|
| 337 | - else { // No pubkey |
|
| 329 | + } else { // No pubkey |
|
| 338 | 330 | $importMessageCert = false; |
| 339 | 331 | Log::write(LOGLEVEL_INFO, sprintf("[smime] Unable to verify message without public key, openssl error: '%s'", $this->openssl_error)); |
| 340 | 332 | $this->message['success'] = SMIME_STATUS_FAIL; |
@@ -404,8 +396,7 @@ discard block |
||
| 404 | 396 | break; |
| 405 | 397 | } |
| 406 | 398 | } |
| 407 | - } |
|
| 408 | - else { |
|
| 399 | + } else { |
|
| 409 | 400 | $decryptStatus = openssl_pkcs7_decrypt($tmpFile, $tmpDecrypted, $certs['cert'], [$certs['pkey'], $pass]); |
| 410 | 401 | } |
| 411 | 402 | |
@@ -437,19 +428,16 @@ discard block |
||
| 437 | 428 | if (strpos($content, 'multipart/signed') !== false || strpos($content, 'signed-data') !== false) { |
| 438 | 429 | $this->message['type'] = 'encryptsigned'; |
| 439 | 430 | $this->verifyMessage($data['message'], $content); |
| 440 | - } |
|
| 441 | - elseif ($decryptStatus) { |
|
| 431 | + } elseif ($decryptStatus) { |
|
| 442 | 432 | $this->message['info'] = SMIME_DECRYPT_SUCCESS; |
| 443 | 433 | $this->message['success'] = SMIME_STATUS_SUCCESS; |
| 444 | - } |
|
| 445 | - elseif ($this->extract_openssl_error() === OPENSSL_RECIPIENT_CERTIFICATE_MISMATCH) { |
|
| 434 | + } elseif ($this->extract_openssl_error() === OPENSSL_RECIPIENT_CERTIFICATE_MISMATCH) { |
|
| 446 | 435 | error_log("[smime] Error when decrypting email, openssl error: " . print_r($this->openssl_error, true)); |
| 447 | 436 | Log::Write(LOGLEVEL_ERROR, sprintf("[smime] Error when decrypting email, openssl error: '%s'", $this->openssl_error)); |
| 448 | 437 | $this->message['info'] = SMIME_DECRYPT_CERT_MISMATCH; |
| 449 | 438 | $this->message['success'] = SMIME_STATUS_FAIL; |
| 450 | 439 | } |
| 451 | - } |
|
| 452 | - else { |
|
| 440 | + } else { |
|
| 453 | 441 | $this->message['info'] = SMIME_UNLOCK_CERT; |
| 454 | 442 | } |
| 455 | 443 | |
@@ -482,18 +470,15 @@ discard block |
||
| 482 | 470 | $this->message['info'] = SMIME_ERROR; |
| 483 | 471 | $this->message['success'] = SMIME_STATUS_FAIL; |
| 484 | 472 | // Verification was successful |
| 485 | - } |
|
| 486 | - elseif ($openssl_return) { |
|
| 473 | + } elseif ($openssl_return) { |
|
| 487 | 474 | $this->message['info'] = SMIME_SUCCESS; |
| 488 | 475 | $this->message['success'] = SMIME_STATUS_SUCCESS; |
| 489 | 476 | // Verification was not successful, display extra information. |
| 490 | - } |
|
| 491 | - else { |
|
| 477 | + } else { |
|
| 492 | 478 | $this->message['success'] = SMIME_STATUS_FAIL; |
| 493 | 479 | if ($openssl_errors === OPENSSL_CA_VERIFY_FAIL) { |
| 494 | 480 | $this->message['info'] = SMIME_CA; |
| 495 | - } |
|
| 496 | - else { // Catch general errors |
|
| 481 | + } else { // Catch general errors |
|
| 497 | 482 | $this->message['info'] = SMIME_ERROR; |
| 498 | 483 | } |
| 499 | 484 | } |
@@ -542,8 +527,7 @@ discard block |
||
| 542 | 527 | // TODO: update to serialNumber check |
| 543 | 528 | if ($certMessage && $certMessage[0][PR_MESSAGE_DELIVERY_TIME] == $publickeyData['validTo_time_t']) { |
| 544 | 529 | $message = _('Certificate is already stored on the server'); |
| 545 | - } |
|
| 546 | - else { |
|
| 530 | + } else { |
|
| 547 | 531 | $saveCert = true; |
| 548 | 532 | $root = mapi_msgstore_openentry($this->getStore(), null); |
| 549 | 533 | // Remove old certificate |
@@ -619,8 +603,7 @@ discard block |
||
| 619 | 603 | if (isset($props[PR_EC_IMAP_EMAIL]) || propIsError(PR_EC_IMAP_EMAIL, $props) == MAPI_E_NOT_ENOUGH_MEMORY) { |
| 620 | 604 | // Stream the message to properly get the PR_EC_IMAP_EMAIL property |
| 621 | 605 | $emlMessageStream = mapi_openproperty($message, PR_EC_IMAP_EMAIL, IID_IStream, 0, 0); |
| 622 | - } |
|
| 623 | - else { |
|
| 606 | + } else { |
|
| 624 | 607 | // Read the message as RFC822-formatted e-mail stream. |
| 625 | 608 | $emlMessageStream = mapi_inetmapi_imtoinet($GLOBALS['mapisession']->getSession(), $GLOBALS['mapisession']->getAddressbook(), $message, []); |
| 626 | 609 | } |
@@ -725,8 +708,7 @@ discard block |
||
| 725 | 708 | Log::Write(LOGLEVEL_ERROR, sprintf("[smime] Unable to sign message with intermediate certificates, openssl error: '%s'", @openssl_error_string())); |
| 726 | 709 | } |
| 727 | 710 | unlink($tmpFile); |
| 728 | - } |
|
| 729 | - else { |
|
| 711 | + } else { |
|
| 730 | 712 | $ok = openssl_pkcs7_sign($infile, $outfile, $certs['cert'], [$certs['pkey'], ''], [], PKCS7_DETACHED); |
| 731 | 713 | if (!$ok) { |
| 732 | 714 | Log::Write(LOGLEVEL_ERROR, sprintf("[smime] Unable to sign message, openssl error: '%s'", @openssl_error_string())); |
@@ -830,8 +812,7 @@ discard block |
||
| 830 | 812 | |
| 831 | 813 | if (!empty($gabCert)) { |
| 832 | 814 | array_push($publicCerts, $gabCert); |
| 833 | - } |
|
| 834 | - elseif (!empty($storeCert)) { |
|
| 815 | + } elseif (!empty($storeCert)) { |
|
| 835 | 816 | array_push($publicCerts, base64_decode($storeCert)); |
| 836 | 817 | } |
| 837 | 818 | } |
@@ -1026,8 +1007,7 @@ discard block |
||
| 1026 | 1007 | |
| 1027 | 1008 | if ($hash === 'sha1') { |
| 1028 | 1009 | $fingerprint = sha1($body); |
| 1029 | - } |
|
| 1030 | - else { |
|
| 1010 | + } else { |
|
| 1031 | 1011 | $fingerprint = md5($body); |
| 1032 | 1012 | } |
| 1033 | 1013 | |
@@ -1052,8 +1032,7 @@ discard block |
||
| 1052 | 1032 | try { |
| 1053 | 1033 | $user = mapi_ab_resolvename($addrbook, $userArr, EMS_AB_ADDRESS_LOOKUP); |
| 1054 | 1034 | $user = mapi_ab_openentry($addrbook, $user[0][PR_ENTRYID]); |
| 1055 | - } |
|
| 1056 | - catch (MAPIException $e) { |
|
| 1035 | + } catch (MAPIException $e) { |
|
| 1057 | 1036 | $e->setHandled(); |
| 1058 | 1037 | } |
| 1059 | 1038 | |
@@ -1126,8 +1105,7 @@ discard block |
||
| 1126 | 1105 | $senderStructure["props"]['display_type'] = isset($userprops[PR_DISPLAY_TYPE]) ? $userprops[PR_DISPLAY_TYPE] : MAPI_MAILUSER; |
| 1127 | 1106 | $senderStructure["props"]['display_type_ex'] = isset($userprops[PR_DISPLAY_TYPE_EX]) ? $userprops[PR_DISPLAY_TYPE_EX] : MAPI_MAILUSER; |
| 1128 | 1107 | } |
| 1129 | - } |
|
| 1130 | - catch (MAPIException $e) { |
|
| 1108 | + } catch (MAPIException $e) { |
|
| 1131 | 1109 | Log::write(LOGLEVEL_ERROR, sprintf("%s %s", $e, $userProps[PR_SENT_REPRESENTING_NAME])); |
| 1132 | 1110 | } |
| 1133 | 1111 | |