Skip to content

Instantly share code, notes, and snippets.

@zoghal
Last active September 26, 2022 06:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zoghal/4b8bb1d055722a178773be6c189e25f9 to your computer and use it in GitHub Desktop.
Save zoghal/4b8bb1d055722a178773be6c189e25f9 to your computer and use it in GitHub Desktop.
مشکل curl در هاست‌های سرورهای داخل ایران
<?php
//$url = 'https://api.wordpress.org';
$url = "https://libre.font-store.ir";
$ch = curl_init();
// CURL options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
//curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPGET, true);
curl_setopt($ch, CURLOPT_VERBOSE, true);
$streamVerboseHandle = fopen("php://temp", "w+");
curl_setopt($ch, CURLOPT_STDERR, $streamVerboseHandle);
echo curl_exec($ch) . "\n";
echo curl_error($ch) . "\n";
rewind($streamVerboseHandle);
$verboseLog = stream_get_contents($streamVerboseHandle);
echo "cUrl verbose information:\n",
"<pre>",
htmlspecialchars($verboseLog),
"</pre>\n";
[root@linux ~]# php -v
PHP 7.4.30 (cli) (built: Sep 6 2022 18:11:45) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with the ionCube PHP Loader + ionCube24 v11.0.1, Copyright (c) 2002-2022, by ionCube Ltd.
with Zend OPcache v7.4.30, Copyright (c), by Zend Technologies
[root@linux ~]#
[root@linux ~]#
[root@linux ~]#
[root@linux ~]# php ss.php
OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to libre.font-store.ir:443
cUrl verbose information:
<pre>* Trying 172.67.129.35:443...
* Connected to libre.font-store.ir (172.67.129.35) port 443 (#0)
* ALPN: offers h2
* ALPN: offers http/1.1
* CAfile: /etc/pki/tls/certs/ca-bundle.crt
* CApath: none
* OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to libre.font-store.ir:443
* Closing connection 0
</pre>
[root@linux4 ~]#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment