I'm trying to use cURL in php, but an error occurs, and nothing is returned in response:

* Hostname was NOT found in DNS cache * Resolving timed out after 5514 milliseconds * Closing connection 0 28: Resolving timed out after 5514 milliseconds 

The code is:

 <?php $url = "https://example.com/rest/checksms/9502ec34-5348-4096-838a-e7ac0cce9d74"; $cert_password = '123456789'; $curl = curl_init(); if ($curl === false) { throw new Exception(' cURL init failed'); } curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_CAPATH, "/home/redmine_dev/curl/client_smsgate-in.pem"); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_HTTPGET, 1); curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 5); curl_setopt($curl, CURLOPT_TIMEOUT, 60); curl_setopt($curl, CURLOPT_VERBOSE, TRUE); curl_setopt($curl, CURLOPT_SSLCERTPASSWD, $cert_password); $result = curl_exec($curl); if ( ! $result) { print curl_errno($curl) .': '. curl_error($curl); } $result = curl_multi_getcontent ($curl); echo "\n".'Login OK'."\n".'[result ===8<===>'."\n".$result."\n".'<===>8=== result]'."\n"; curl_close($curl); 

With that, if you just use cURL from the command line: curl "https://example.com/rest/checksms/9502ec34-5348-4096-838a-e7ac0cce9d74" --cert ./client_smsgate-in.pem:123456789 -k

Domain https://example.com/ rezolvitsya network pings pass. Tell me what could be the problem?

UPDATE: At the same time, I noticed that this error occurs as the script is run for the first time, if after completion it is immediately launched again, it crashes: error: 14094410: SSL routines: SSL3_READ_BYTES: sslv3 alert handshake failure. php -v :

 PHP 5.6.20-0+deb8u1 (cli) (built: Apr 27 2016 11:26:05) Copyright (c) 1997-2016 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies` 

curl --version :

 curl 7.38.0 (x86_64-pc-linux-gnu) libcurl/7.38.0 OpenSSL/1.0.1k zlib/1.2.8 libidn/1.29 libssh2/1.4.3 librtmp/2.3 Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp scp sftp smtp smtps telnet tftp Features: AsynchDNS IDN IPv6 Largefile GSS-API SPNEGO NTLM NTLM_WB SSL libz TLS-SRP 

httpd -v :

 Server version: Apache/2.2.15 (Unix) Server built: Feb 9 2016 17:28:49 
  • Increasing the timeout does not solve the problem? - VenZell
  • @VenZell, no, set 500, did not help. At the same time, I noticed that this error occurs as the script is run for the first time, if after the completion it is immediately launched again, it will error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure - S.Ivanov
  • Try adding the CURLOPT_SSL_CIPHER_LIST option with the value TLSv1 and check if you have ssl connections in Apache. In particular, TLS. - VenZell
  • Add an update from the comment to the question. Specify the question version of php, curl and apache - VenZell
  • @VenZell, put TLSv1 did not help. I don’t use the Apache, I just run the script from the command line - S.Ivanov

0