1 | <?php |
---|
2 | |
---|
3 | ini_set( 'display_errors', true ); |
---|
4 | error_reporting( E_ALL ); |
---|
5 | |
---|
6 | echo "WITH VERIFY_PEER\n"; |
---|
7 | $context = stream_context_create( array( |
---|
8 | 'ssl' => array( |
---|
9 | 'verify_peer' => true, |
---|
10 | ), |
---|
11 | ) ); |
---|
12 | |
---|
13 | $a = fopen( 'https://wordpress.org/', 'r', false, $context ); |
---|
14 | echo $a ? "YES" : "NO"; |
---|
15 | echo "\n"; |
---|
16 | |
---|
17 | echo "\n"; |
---|
18 | |
---|
19 | echo "WITHOUT VERIFY_PEER\n"; |
---|
20 | $context = stream_context_create( array( |
---|
21 | 'ssl' => array( |
---|
22 | 'verify_peer' => false |
---|
23 | ), |
---|
24 | ) ); |
---|
25 | |
---|
26 | $a = fopen( 'https://wordpress.org/', 'r', false, $context ); |
---|
27 | echo $a ? "YES" : "NO"; |
---|
28 | echo "\n"; |
---|
29 | |
---|
30 | echo "\n"; |
---|
31 | |
---|
32 | echo "CURL CONTROL\n"; |
---|
33 | $c = curl_init( 'https://wordpress.org/' ); |
---|
34 | curl_setopt_array( $c, array( |
---|
35 | CURLOPT_NOBODY => true, |
---|
36 | CURLOPT_SSL_VERIFYHOST => true, |
---|
37 | CURLOPT_SSL_VERIFYPEER => true, |
---|
38 | ) ); |
---|
39 | $a = curl_exec( $c ); |
---|
40 | echo $a ? "YES" : "NO"; |
---|
41 | echo "\n"; |
---|