Error - PHP - cURL - Unknown SSL protocol error in connection -

php curl unknown ssl protocol error in connection to 443
curl error: 35 (ssl_connect_error)
docker curl: (35) unknown ssl protocol error in connection to
unknown ssl protocol error in connection to api twitter com 443
curl unknown error
curl error 35 error:140770fc:ssl routines:ssl23_get_server_hello:unknown protocol
unknown ssl protocol error in connection to opendata maryland gov 443
curl ssl error
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $xml_url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_HEADER, false);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 0);

$xml = curl_exec($ch);

if(curl_exec($ch) === false) 
{ echo curl_error($ch); }
else 
{ echo 'Operation completed without any errors'; }

curl_close($ch);
return $xml;

Above code is giving below error.

Unknown SSL protocol error in connection to api.site.com:443

As per suggested by many people that below code will resolve above issue but it is not helping. Still getting same error.

curl_setopt ($ch, CURLOPT_SSLVERSION, 3);

I tried below also as per suggestions but still getting same error.

curl_setopt ($ch, CURLOPT_SSLVERSION, 'CURL_SSLVERSION_SSLv3' );

Please suggest what else I should put in code to fix this error.

Thank you,

You just ignored the SSL certificate verification, may be it will help you to resolve the problem, use the code below when requesting with CURL.

curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

curl "Unknown SSL protocol error in connection" error in server, but , Unknown SSL protocol error in connection to tlstest.paypal.com:443 after When running from CLI make sure to include the following CURL OPT: PHP uses its own installation of openssl, and its version can only be  Teams. Q&A for Work. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information.

You may try this code.

$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $xml_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt ($ch, CURLOPT_HEADER, false);

$xml = curl_exec($ch);

if($xml === false) { 
    echo curl_error($ch); 
}else{ 
    echo 'Operation completed without any errors'; 
}
curl_close($ch);
return $xml;

Also you may use this class for curl request,

https://gist.github.com/sourovroy/1fba93188470bbe3eefa15cd17533b23

Unknown SSL protocol error in connection to tlstest.paypal.com:443 , The error being returned is: cURL Error #:Unknown SSL protocol error in connection to I'm working in PHP on a Linux webserver. $ curl -2 https://192.168.101.1 curl: (35) Unknown SSL protocol error in connection to 192.168.101.1:443 In this case, on this particular server, it supports only TLS.

You could check which TLS version the website uses with curl verbose mode:

curl_setopt($curl, CURLOPT_VERBOSE, true);

Where the output will be like this:

...
SSL connection using TLS1.0 / RSA_3DES_EDE_CBC_SHA1
...

Then set CURLOPT_SSL_CIPHER_LIST like this:

curl_setopt($curl, CURLOPT_SSL_CIPHER_LIST, "TLSv1");

Where "TLSv1" is the TLS version the website uses.

Changing SSL version and VERIFY_PEER/HOST in curl options didn't solve my problem, but this approach did.

cURL Error #:Unknown SSL protocol error, Internal error: Error in cURL request: Unknown SSL protocol error in OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to  curl -v https: // my.pg.server * About to connect to my.pg.server port 443 (#0) * Trying 2001:e48: 44: 4::d0 connected * Connected to my.pg.server (2001:e48: 44: 4::d0) port 443 (#0) * successfully set certificate verify locations: * CAfile: / etc / pki / tls / certs / ca-bundle.crt CApath: none * SSLv3, TLS handshake, Client hello (1

Unable to open File Sharing menu: Error in cURL request: Unknown , curl -2 https://192.168.101.1 curl: (35) Unknown SSL protocol error in connection to 192.168.101.1:443. In this case, on this particular server,  I did this Actually this bug originates from my own www page with php and libcurl. However I noticed the same bug is in the command line version of curl as well, which makes it much easier for you to debug.

How to Fix Curl TLS SSL Protocol Issue from CLI and PHP Code, 3 common (and 1 uncommon) causes of the 'Unknown SSL protocol error in connection to' error in cURL and other apps that use openssl. #1681 is another report with the same curl on stretch, but that only affected a select host.. On the affected computer use wireshark and set capture filter host test.com and then run curl https://test.com.

3 Common Causes of Unknown SSL Protocol Errors with cURL , We get the "cURL error 35" error, but only some. cURL error 35: Unknown SSL protocol error in connection to api.twitter.com:443 SSL protocol error in connection to api.twitter.com:443 in TwitterOAuth.php (line  * Connected to servicios1.afip.gov.ar (200.1.116.53) port 443 (#0) * Unsupported SSL protocol version * Closing connection 0 curl: (35) Unsupported SSL protocol version That's from my archlinux server, while on my desktop's fedora it works just fine.

Comments
  • which curl version are you using?
  • @DarshanJain, libcurl/7.21.0 OpenSSL/0.9.8q zlib/1.2.3 - this is mentioned in php info.
  • Ty for your reply but still getting same error even after using above mentioned code.