From 64a1c3c2ac191581dd73b486463e707f56984e6b Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Thu, 5 Aug 2021 14:42:04 +0100 Subject: [PATCH] [1.x] Avoids usage of `SWOOLE_SSL` when `openssl` is not configured on swoole (#357) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Only uses SWOOLE_SSL if exists * Adds guard Co-Authored-By: 沈唁 Co-authored-by: 沈唁 --- bin/createSwooleServer.php | 4 +++- src/Commands/StartSwooleCommand.php | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/bin/createSwooleServer.php b/bin/createSwooleServer.php index 19f1d5372..764677f18 100644 --- a/bin/createSwooleServer.php +++ b/bin/createSwooleServer.php @@ -7,7 +7,9 @@ $serverState['host'] ?? '127.0.0.1', $serverState['port'] ?? '8080', SWOOLE_PROCESS, - SWOOLE_SOCK_TCP | ((bool) ($config['swoole']['ssl'] ?? 0)) * SWOOLE_SSL, + ($config['swoole']['ssl'] ?? false) + ? SWOOLE_SOCK_TCP | SWOOLE_SSL + : SWOOLE_SOCK_TCP, ); } catch (Throwable $e) { Laravel\Octane\Stream::shutdown($e); diff --git a/src/Commands/StartSwooleCommand.php b/src/Commands/StartSwooleCommand.php index a7cf5e7a4..6c52ac555 100644 --- a/src/Commands/StartSwooleCommand.php +++ b/src/Commands/StartSwooleCommand.php @@ -66,6 +66,12 @@ public function handle( return 1; } + if (config('octane.swoole.ssl', false) === true && ! defined('SWOOLE_SSL')) { + $this->error('You must configure Swoole with `--enable-openssl` to support ssl.'); + + return 1; + } + $this->writeServerStateFile($serverStateFile, $extension); $this->forgetEnvironmentVariables();