Skip to content

Commit b79e21c

Browse files
authored
Merge pull request #1359 from driskell/fix-openssl-padding-php-lt-81
1 parent 78f8576 commit b79e21c

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/PhpBrew/VariantBuilder.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,16 @@ public function __construct()
237237
new IncludePrefixFinder('openssl/opensslv.h'),
238238
));
239239

240+
// OpenSSL 3 removes RSA_SSLV23_PADDING and so is not compatible with PHP < 8.1, and Homebrew defaults to openssl@3
241+
// If we detect homebrew openssl@3, which is the default, change it to [email protected]
242+
// Fixed in PHP since 8.1.0: https://github.com/php/php-src/commit/a0972deb0f441fc7991001cb51efc994b70a3b51
243+
if ($opensslPrefix !== null && $build->compareVersion('8.1') < 0 && $opensslPrefix === (new BrewPrefixFinder('openssl@3'))->findPrefix()) {
244+
$opensslPrefix = (new BrewPrefixFinder('[email protected]'))->findPrefix();
245+
if ($opensslPrefix === null) {
246+
throw new Exception('PHP < 8.1 requires [email protected].');
247+
}
248+
}
249+
240250
return $params->withOption('--with-imap', $imapPrefix)
241251
->withOptionOrPkgConfigPath($build, '--with-kerberos', $kerberosPrefix)
242252
->withOptionOrPkgConfigPath($build, '--with-imap-ssl', $opensslPrefix);
@@ -553,6 +563,16 @@ public function __construct()
553563
new IncludePrefixFinder('openssl/opensslv.h'),
554564
));
555565

566+
// OpenSSL 3 removes RSA_SSLV23_PADDING and so is not compatible with PHP < 8.1, and Homebrew defaults to openssl@3
567+
// If we detect homebrew openssl@3, which is the default, change it to [email protected]
568+
// Fixed in PHP since 8.1.0: https://github.com/php/php-src/commit/a0972deb0f441fc7991001cb51efc994b70a3b51
569+
if ($prefix !== null && $build->compareVersion('8.1') < 0 && $prefix === (new BrewPrefixFinder('openssl@3'))->findPrefix()) {
570+
$prefix = (new BrewPrefixFinder('[email protected]'))->findPrefix();
571+
if ($prefix === null) {
572+
throw new Exception('PHP < 8.1 requires [email protected].');
573+
}
574+
}
575+
556576
return $parameters->withOptionOrPkgConfigPath($build, '--with-openssl', $prefix);
557577
};
558578

0 commit comments

Comments
 (0)