1

This is not related to homestead nor vagrant nor laravel.

I have an app service running on PHP 7.3 on a Windows Azure server.

Here's the code I'm running in relation to my cURL call:

$resCurl = curl_init();

$url_API = 'https://example.com/api/someMethod';

curl_setopt( $resCurl, CURLOPT_HTTPHEADER,  array( 'Content-type: APPLICATION/JSON; CHARSET=UTF-8' ) );
curl_setopt( $resCurl, CURLOPT_POSTFIELDS, $jsonRequest );

curl_setopt( $resCurl, CURLOPT_POST, true );
curl_setopt( $resCurl, CURLOPT_URL, $url_API );
curl_setopt( $resCurl, CURLOPT_RETURNTRANSFER, 1);

$resultAPI = curl_exec( $resCurl );

When this is executed, I keep on generating this error:

Curl error: OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 10054

Running the command prompt, I can execute php -i to see if openssl has a directory it's reading from as well a file mentioned:

Open SSL Version and configuration

I've already checked the directory and downloaded the most up-to-date cacert.pem file from here: https://curl.haxx.se/docs/sslcerts.html

I DO NOT want to solve this issue through turning off SSL verification by setting my CURLOPT_SSL_VERIFYHOST and CURLOPT_SSL_VERIFYPEER to false.

Any advice?

UPDATE:

I hardcoded options for both CURLOPT_SSLCERT and CURLOPT_SSLCERTTYPE:

curl_setopt( $resCurl, CURLOPT_SSLCERT, 'D:\home\site\cert\cacert.pem');
curl_setopt( $resCurl, CURLOPT_SSLCERTTYPE, 'PEM' );

And the error is different now:

unable to set private key file: 'D:\home\site\cert\cacert.pem' type PEM

I would upload a private key, but there are no private keys for this public cacert.

LatentDenis
  • 2,839
  • 12
  • 48
  • 99
  • 2
    Error `10054` means "Connection reset by peer" indicating there is some kind of connection issue going on between the client and server. Perhaps interrupted by a firewall or routing issue. – drew010 Nov 11 '19 at 16:15
  • 1
    @Drew010 you wer right it was a firewall issue, post an answer and I'll accept if Jack Jia doesn't get to it first – LatentDenis Nov 16 '19 at 17:45

2 Answers2

1

Based on my test, everything is OK.

My environment:

  1. Windows 10 1809
  2. PHP 7.3 (7.3.11)
  3. cacert from https://curl.haxx.se/ca/cacert.pem

Code:

    $resCurl = curl_init();

    $url_API = 'https://example.com/api/someMethod';
    $jsonRequest = '{"a":"aaa"}';
    curl_setopt( $resCurl, CURLOPT_HTTPHEADER,  array( 'Content-type: APPLICATION/JSON; CHARSET=UTF-8' ) );
    curl_setopt( $resCurl, CURLOPT_POSTFIELDS, $jsonRequest );

    curl_setopt( $resCurl, CURLOPT_POST, true );
    curl_setopt( $resCurl, CURLOPT_URL, $url_API );
    curl_setopt( $resCurl, CURLOPT_RETURNTRANSFER, 1);

    $resultAPI = curl_exec( $resCurl );
    $print_r($resultAPI)

Result:

enter image description here


Suggestion

So, basically this part of code is fine.

As you said that it is not related to homestead nor vagrant nor laravel. So, it is most likely a network issue. Maybe you can try to restart the Azure server.


Update

Confirmed by @LatentDenis, he finally found that the problem was caused by the firewall, which can give us a clue to narrow down similiar issues.

Jack Jia
  • 5,268
  • 1
  • 12
  • 14
  • Thanks for testing on your end, I went ahead and updated my question at the end - do you know anything about the new error being generated? – LatentDenis Nov 12 '19 at 15:21
  • I realize the issue, the resource I was attempting to access had our IPs blocked. If you revise your answer to say account for blocks on the server (firewall issues) I'll accept! – LatentDenis Nov 16 '19 at 17:44
  • @LatentDenis Your case would point out a direction to others who have similiar issues. Updated in my answer. Thanks. – Jack Jia Nov 17 '19 at 12:37
0

I have installed Version 2.0.2 Installer Version. Download

and other solution you can found on this below link :

error rpc failed curl

Chintan
  • 123
  • 1
  • 14