Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sudo openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout apache.key -out apache.crt
- apache.crt apache.key > joined.pem
- <?php
- ini_set('display_errors', 1);
- ini_set('display_startup_errors', 1);
- error_reporting(E_ALL);
- $flags = STREAM_SERVER_BIND|STREAM_SERVER_LISTEN;
- $ctx = stream_context_create(['ssl' => [
- 'local_cert' => "{path}/Websites/127.0.0.1/certs/joined.pem",
- 'SNI_server_certs' => [
- "127.0.0.1" => "{path}/Websites/127.0.0.1/certs/joined.pem",
- "localhost" => "{path}//Websites/localhost/certs/joined.pem",
- ]
- ]]);
- stream_context_set_option($ctx, 'ssl', 'ssl_method', 'STREAM_CRYPTO_METHOD_TLSv23_SERVER');
- stream_context_set_option($ctx, 'ssl', 'allow_self_signed', true);
- stream_context_set_option($ctx, 'ssl', 'verify_peer', false);
- stream_context_set_option($ctx, 'ssl', 'ciphers', "HIGH");
- $socket = stream_socket_server("tls://127.0.0.1:8443", $errno, $errstr, $flags, $ctx);
- while ( $client = stream_socket_accept($socket, "-1", $clientIP)):
- $msg = fread($client, 8192);
- $resp = "HTTP/1.1 200 OKrnContent-type: text/htmlrnrn<h1>Hi, you are secured.<br>{$msg}";
- fwrite($client,$resp );
- fclose($client);
- endwhile;
Add Comment
Please, Sign In to add comment