Skip to content

Commit

Permalink
Merge pull request #4548 from LibreSign/backport/4547/stable29
Browse files Browse the repository at this point in the history
[stable29] fix: prevent warning of fsockopen
  • Loading branch information
vitormattos authored Jan 29, 2025
2 parents 296ffb1 + fa2dc59 commit d490ea8
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions lib/Handler/CertificateEngine/CfsslHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,15 +288,13 @@ private function wakeUp(): void {
private function portOpen(): bool {
$host = parse_url($this->getCfsslUri(), PHP_URL_HOST);
$port = parse_url($this->getCfsslUri(), PHP_URL_PORT);
try {
$socket = fsockopen($host, $port, $errno, $errstr, 0.1);
} catch (\Throwable $th) {
}
if (isset($socket) && is_resource($socket)) {
fclose($socket);
return true;
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if (!$socket) {
return false;
}
return false;
socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, ['sec' => 0, 'usec' => 100000]); // 100ms
socket_set_option($socket, SOL_SOCKET, SO_SNDTIMEO, ['sec' => 0, 'usec' => 100000]);
return @socket_connect($socket, $host, $port);
}

private function getServerPid(): int {
Expand Down

0 comments on commit d490ea8

Please sign in to comment.