Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.

Commit 260a4aa

Browse files
committed
add support for ssl config
1 parent fbcee17 commit 260a4aa

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

config/swoole_http.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
'max_request' => 3000,
3636
// Enable coroutine send
3737
'send_yield' => true,
38+
// You must --enable-openssl while compiling Swoole
39+
'ssl_cert_file' => null,
40+
'ssl_key_file' => null,
3841
],
3942
],
4043

src/Server/Manager.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,11 @@ protected function createSwooleServer()
140140
$server = $this->isWebsocket ? WebsocketServer::class : HttpServer::class;
141141
$host = $this->container['config']->get('swoole_http.server.host');
142142
$port = $this->container['config']->get('swoole_http.server.port');
143+
$hasCert = $this->container['config']->get('swoole_http.server.options.ssl_cert_file');
144+
$hasKey = $this->container['config']->get('swoole_http.server.options.ssl_key_file');
145+
$args = $hasCert && $hasKey ? [SWOOLE_PROCESS, SWOOLE_SOCK_TCP | SWOOLE_SSL] : [];
143146

144-
$this->server = new $server($host, $port);
147+
$this->server = new $server($host, $port, ...$args);
145148
}
146149

147150
/**

0 commit comments

Comments
 (0)