note 120278 added to context.ssl
| From: | Charlie | Date: | Mon, 05 Dec 2016 19:53:48 +0000 |
| Subject: | note 120278 added to context.ssl | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-208229@lists.php.net to get a copy of this message | ||
I am unable to load a PEM that was generated with the stunnel tools. However, I am able to use PHP
calls to generate a working PEM that is recognized both by stunnel and php, as outlined here:
http://www.devdungeon.com/content/how-use-ssl-sockets-php
This code fragment is now working for me, and with stunnel verify=4, both sides confirm the
fingerprint. Oddly, if "tls://" is set below, then TLSv1 is forced, but using
"ssl://" allows TLSv1.2:
$stream_context = stream_context_create([ 'ssl' => [
'local_cert' => '/path/to/key.pem',
'peer_fingerprint' =>
openssl_x509_fingerprint(file_get_contents('/path/to/key.crt')),
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true,
'verify_depth' => 0 ]]);
$fp = stream_socket_client('ssl://ssl.server.com:12345',
$errno, $errstr, 30, STREAM_CLIENT_CONNECT, $stream_context);
fwrite($fp, "foo bar\n");
while($line = fgets($fp, 8192)) echo $line;
----
Server IP: 72.52.91.14
Probable Submitter: 142.79.57.1
----
Manual Page -- http://php.net/manual/en/context.ssl.php
Edit -- https://master.php.net/note/edit/120278
Del: integrated -- https://master.php.net/note/delete/120278/integrated
Del: useless -- https://master.php.net/note/delete/120278/useless
Del: bad code -- https://master.php.net/note/delete/120278/bad+code
Del: spam -- https://master.php.net/note/delete/120278/spam
Del: non-english -- https://master.php.net/note/delete/120278/non-english
Del: in docs -- https://master.php.net/note/delete/120278/in+docs
Del: other reasons-- https://master.php.net/note/delete/120278
Reject -- https://master.php.net/note/reject/120278
Search -- https://master.php.net/manage/user-notes.php