Skip to content

Commit

Permalink
PHP 8.1 deprecated openssl_pkey_free 함수 수정
Browse files Browse the repository at this point in the history
8.1부터는 자동으로 메모리에서 해제가 되게 바뀌어서
8이하에서만 작동되게 수정.
  • Loading branch information
kitrio committed May 31, 2022
1 parent df295bf commit 5465e07
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions plugin/PHPMailer/class.phpmailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -3818,7 +3818,9 @@ public function DKIM_Sign($signHeader)
if (version_compare(PHP_VERSION, '5.3.0') >= 0 and
in_array('sha256WithRSAEncryption', openssl_get_md_methods(true))) {
if (openssl_sign($signHeader, $signature, $privKey, 'sha256WithRSAEncryption')) {
openssl_pkey_free($privKey);
if (PHP_MAJOR_VERSION < 8) {
openssl_pkey_free($privKey);
}
return base64_encode($signature);
}
} else {
Expand All @@ -3831,11 +3833,15 @@ public function DKIM_Sign($signHeader)
$eb = pack('H*', '0001' . str_repeat('FF', $pslen) . '00' . $t);

if (openssl_private_encrypt($eb, $signature, $privKey, OPENSSL_NO_PADDING)) {
openssl_pkey_free($privKey);
if (PHP_MAJOR_VERSION < 8) {
openssl_pkey_free($privKey);
}
return base64_encode($signature);
}
}
openssl_pkey_free($privKey);
if (PHP_MAJOR_VERSION < 8) {
openssl_pkey_free($privKey);
}
return '';
}

Expand Down

0 comments on commit 5465e07

Please sign in to comment.