xref: /PHP-8.2/ext/openssl/tests/bug65538_002.phpt (revision 74859783)
1--TEST--
2Bug #65538: SSL context "cafile" disallows URL stream wrappers
3--EXTENSIONS--
4openssl
5--SKIPIF--
6<?php
7if (getenv("SKIP_ONLINE_TESTS")) die("skip online test");
8?>
9--FILE--
10<?php
11$clientCtx = stream_context_create(['ssl' => [
12    // We don't get any ca list from php.net but it does not matter as we
13    // care about the fact that the external stream is not allowed.
14    // We can't use http://curl.haxx.se/ca/cacert.pem for this test
15    // as it is redirected to https which means the test would depend
16    // on system cafile when opening stream.
17    'cafile' => 'http://www.nginx.org',
18]]);
19file_get_contents('https://github.com', false, $clientCtx);
20?>
21--EXPECTF--
22Warning: remote cafile streams are disabled for security purposes in %s on line %d
23
24Warning: file_get_contents(): Failed to enable crypto in %s on line %d
25
26Warning: file_get_contents(%s): Failed to open stream: operation failed in %s on line %d
27