From 87ff04ebaf0f3fca5a8af3c95fe5562fb663875d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Muhammet=20=C5=9Eafak?= Date: Mon, 23 Nov 2026 11:45:10 +0300 Subject: [PATCH] docs: keep TLS verification on in the SSL client examples - Remove the `verify_peer` / `verify_peer_name` overrides from the README, Transport SSL and SMTP client examples; verification is on by default - Update the SMTP recipe note accordingly --- README.md | 6 +++--- docs/Recipe-SMTP-Client.md | 8 ++++---- docs/Transport-SSL.md | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index b08f449..f92bff8 100644 --- a/README.md +++ b/README.md @@ -132,9 +132,9 @@ $server->live(function (SocketServerInterface $srv, SocketConnectionInterface $c use InitPHP\Socket\Socket; use InitPHP\Socket\Enum\Transport; -$client = Socket::client(Transport::SSL, 'smtp.gmail.com', 465, timeout: 10.0) - ->option('verify_peer', false) - ->option('verify_peer_name', false); +// The server certificate and host name are verified against the system trust +// store by default (verify_peer / verify_peer_name are on) — leave them on. +$client = Socket::client(Transport::SSL, 'smtp.gmail.com', 465, timeout: 10.0); $client->connect(); $client->write("EHLO [127.0.0.1]\r\n"); diff --git a/docs/Recipe-SMTP-Client.md b/docs/Recipe-SMTP-Client.md index 0807cc0..c13571f 100644 --- a/docs/Recipe-SMTP-Client.md +++ b/docs/Recipe-SMTP-Client.md @@ -13,9 +13,9 @@ require __DIR__ . '/vendor/autoload.php'; use InitPHP\Socket\Socket; use InitPHP\Socket\Enum\Transport; -$client = Socket::client(Transport::SSL, 'smtp.gmail.com', 465, timeout: 10.0) - ->option('verify_peer', false) - ->option('verify_peer_name', false); +// Certificate and host-name verification stay on (the default): the server's +// certificate is checked against the system trust store. +$client = Socket::client(Transport::SSL, 'smtp.gmail.com', 465, timeout: 10.0); $client->connect(); @@ -47,7 +47,7 @@ Expected output (truncated): - **`Transport::SSL`** — Gmail's port 465 serves implicit TLS; the connection is encrypted from the first byte. For port 587 you would start with `Transport::TCP` and upgrade in place with `crypto()` after `STARTTLS`. - **`timeout: 10.0`** — the connect (and TLS handshake) must finish inside this budget. -- **`verify_peer`** is set to `false` here to keep the snippet self-contained. **In production** point `cafile` at the system trust store (`/etc/ssl/certs/ca-certificates.crt` on Debian/Ubuntu, `/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem` on RHEL/Alma) and leave `verify_peer` on. +- **No `verify_peer` override** — peer and host-name verification are on by default, so the snippet needs no TLS options for a server with a publicly trusted certificate such as Gmail's. If PHP cannot find your system trust store, set `cafile` to it (`/etc/ssl/certs/ca-certificates.crt` on Debian/Ubuntu, `/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem` on RHEL/Alma) instead of turning verification off. Never disable `verify_peer` once you add `AUTH`: a man-in-the-middle could read the credentials. ## Reading SMTP responses cleanly diff --git a/docs/Transport-SSL.md b/docs/Transport-SSL.md index 70f4805..2da52f2 100644 --- a/docs/Transport-SSL.md +++ b/docs/Transport-SSL.md @@ -36,9 +36,9 @@ Every configuration knob, lifecycle method and exception type is identical to [T use InitPHP\Socket\Socket; use InitPHP\Socket\Enum\Transport; -$client = Socket::client(Transport::SSL, 'smtp.gmail.com', 465, timeout: 10.0) - ->option('verify_peer', false) - ->option('verify_peer_name', false); +// The server certificate and host name are verified against the system trust +// store by default (verify_peer / verify_peer_name are on) — leave them on. +$client = Socket::client(Transport::SSL, 'smtp.gmail.com', 465, timeout: 10.0); $client->connect(); $client->write("EHLO [127.0.0.1]\r\n");