Skip to content

Commit

Permalink
Workaround for PHP bug https://bugs.php.net/bug.php?id=69197
Browse files Browse the repository at this point in the history
  • Loading branch information
Synchro committed Mar 6, 2015
1 parent 3e3617d commit d89d3b0
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions class.phpmailer.php
Expand Up @@ -1834,7 +1834,6 @@ public function getSentMIMEMessage()
return $this->MIMEHeader . $this->mailHeader . self::CRLF . $this->MIMEBody;
}


/**
* Assemble the message body.
* Returns an empty string on failure.
Expand Down Expand Up @@ -1973,16 +1972,27 @@ public function createBody()
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);
Expand Down

0 comments on commit d89d3b0

Please sign in to comment.