Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
8 changes: 4 additions & 4 deletions docs/Recipe-SMTP-Client.md
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions docs/Transport-SSL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down