From d89d3b03b0a2108274bf3ddefd6978b1a1332407 Mon Sep 17 00:00:00 2001 From: Synchro Date: Fri, 6 Mar 2015 18:39:30 +0100 Subject: [PATCH] Workaround for PHP bug https://bugs.php.net/bug.php?id=69197 --- class.phpmailer.php | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/class.phpmailer.php b/class.phpmailer.php index e45b3070..679bd26b 100644 --- a/class.phpmailer.php +++ b/class.phpmailer.php @@ -1834,7 +1834,6 @@ class PHPMailer return $this->MIMEHeader . $this->mailHeader . self::CRLF . $this->MIMEBody; } - /** * Assemble the message body. * Returns an empty string on failure. @@ -1973,16 +1972,27 @@ class PHPMailer throw new phpmailerException($this->lang('signing') . ' Could not write temp file'); } $signed = tempnam(sys_get_temp_dir(), 'signed'); - if (@openssl_pkcs7_sign( - $file, - $signed, - 'file://' . realpath($this->sign_cert_file), - array('file://' . realpath($this->sign_key_file), $this->sign_key_pass), - null, - PKCS7_DETACHED, - $this->sign_extracerts_file - ) - ) { + //Workaround for PHP bug https://bugs.php.net/bug.php?id=69197 + if (empty($this->sign_extracerts_file)) { + $sign = @openssl_pkcs7_sign( + $file, + $signed, + 'file://' . realpath($this->sign_cert_file), + array('file://' . realpath($this->sign_key_file), $this->sign_key_pass), + null + ); + } else { + $sign = @openssl_pkcs7_sign( + $file, + $signed, + 'file://' . realpath($this->sign_cert_file), + array('file://' . realpath($this->sign_key_file), $this->sign_key_pass), + null, + PKCS7_DETACHED, + $this->sign_extracerts_file + ); + } + if ($sign) { @unlink($file); $body = file_get_contents($signed); @unlink($signed);