mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
refactor(client): let caller own TLS verification policy
Replace the hardcoded ssl_verify_peer=false with a $tlsOptions array merged into the socket options when TLS is enabled. The driver provides the TLS mechanism; the consumer decides verification — verify against the system CA in production, or relax it where the endpoint presents an untrusted certificate (e.g. a staging Let's Encrypt staging cert). Avoids baking a verification downgrade into the driver for all environments. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
8e872f7778
commit
1fc279eb27
1 file changed
+8
-6
+8
-6
@@ -143,7 +143,8 @@ class Client
|
||||
string $user,
|
||||
string $password,
|
||||
bool $useCoroutine = false,
|
||||
bool $tls = false
|
||||
bool $tls = false,
|
||||
array $tlsOptions = []
|
||||
) {
|
||||
if (empty($database)) {
|
||||
throw new \InvalidArgumentException('Database name cannot be empty');
|
||||
@@ -197,11 +198,12 @@ class Client
|
||||
];
|
||||
|
||||
if ($tls) {
|
||||
// The backend is reached through a TLS-terminating proxy presenting a
|
||||
// trusted platform certificate; encrypt the hop without enforcing peer
|
||||
// verification (the proxy hostname is not on the backend's own cert).
|
||||
$options['ssl_verify_peer'] = false;
|
||||
$options['ssl_allow_self_signed'] = true;
|
||||
// TLS is the mechanism; the caller owns the verification policy. Pass
|
||||
// ssl_verify_peer / ssl_cafile / ssl_host_name (etc.) via $tlsOptions —
|
||||
// e.g. verify against the system CA in production, or relax verification
|
||||
// where the endpoint presents an untrusted certificate. Defaults to
|
||||
// Swoole's behaviour when no options are given.
|
||||
$options = array_merge($options, $tlsOptions);
|
||||
}
|
||||
|
||||
$this->client->set($options);
|
||||
|
||||
Reference in new issue
Block a user