note 128999 added to function.stream-socket-enable-crypto

From: Date: Sat, 04 Nov 2023 11:44:58 +0000
Subject: note 128999 added to function.stream-socket-enable-crypto
Groups: php.notes 
Request: Send a blank email to php-notes+get-220955@lists.php.net to get a copy of this message
Information to the difference of crypto_method There is STREAM_CRYPTO_METHOD_*_CLIENT and STREAM_CRYPTO_METHOD_*_SERVER STREAM_CRYPTO_METHOD_*_CLIENT is used for clients, like: ```php <?php $client = stream_socket_client("tcp://example.com:443", $errno, $errstr); stream_socket_enable_crypto($client, true, STREAM_CRYPTO_METHOD_TLS_CLIENT); //... ?> ``` This code makes a TLS Handshake and the stream_socket_enable_crypto sends a Client HELLO STREAM_CRYPTO_METHOD_*_SERVER is used for servers, like: <?php $server = stream_socket_server("tcp://example.com:443", $errno, $errstr, STREAM_SERVER_BIND | STREAM_SERVER_LISTEN); stream_context_set_option($server, ["ssl" => [ "local_cert" => __DIR__."/https.crt", "local_pk" => __DIR__."/https.key", ]]); //... $client = stream_socket_accept($server); stream_socket_enable_crypto($client, true, STREAM_CRYPTO_METHOD_TLS_SERVER); //... ?> This code makes a TLS Handshake and the stream_socket_enable_crypto sends a Server HELLO after the client send a Client HELLO. so use STREAM_CRYPTO_METHOD_*_CLIENT for requesting data and STREAM_CRYPTO_METHOD_*_SERVER for serving data, after accepting a client. ---- Server IP: 45.112.84.4 Probable Submitter: 45.91.157.134 (proxied: 84.62.142.240) ---- Manual Page -- https://php.net/manual/en/function.stream-socket-enable-crypto.php Edit -- https://main.php.net/note/edit/128999 Del: integrated -- https://main.php.net/note/delete/128999/integrated Del: useless -- https://main.php.net/note/delete/128999/useless Del: bad code -- https://main.php.net/note/delete/128999/bad+code Del: spam -- https://main.php.net/note/delete/128999/spam Del: non-english -- https://main.php.net/note/delete/128999/non-english Del: in docs -- https://main.php.net/note/delete/128999/in+docs Del: other reasons-- https://main.php.net/note/delete/128999 Reject -- https://main.php.net/note/reject/128999 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#220955) next »