bunq / sdk_php

PHP SDK for bunq API
MIT License
84 stars 54 forks source link

cURL error 0 #7

Closed SebastiaanKloos closed 7 years ago

SebastiaanKloos commented 7 years ago

When I use the ApiContext::create() function I get a cURL error. Does anybody know why this error shows up or how to fix it?

An unexpected error occurred: cURL error 0: The cURL request was retried 3 times and did not succeed. The most likely reason for the failure is that cURL was unable to rewind the body of the request and subsequent retries resulted in the same error. Turn on the debug option to see what went wrong. See https://bugs.php.net/bug.php?id=47204 for more information. (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)

Update: I get the same issue when I use the install command

dnl-blkv commented 7 years ago

@SebastiaanKloos It might be related to Certificate Pinning. Which cURL version are you using? Is it built with OpenSSL?

SebastiaanKloos commented 7 years ago

@dnl-blkv The project is running on my local machine. I'm using the latest version of Laravel Valet running cURL version 7.51.0. Do I need to run my project on a production server?

SebastiaanKloos commented 7 years ago

@dnl-blkv Would a proxy fix my issue?

OGKevin commented 7 years ago

@SebastiaanKloos a quick and cheap fix you can use for now while we look into this issue is to comment out this line: https://github.com/bunq/sdk_php/blob/93ab9b472b389ae02fffab1de33df81c959794e3/lib/Http/ApiClient.php#L163

Also can you provide the outcome of the fowling command form your terminal curl --version ?

SebastiaanKloos commented 7 years ago

@OGKevin Thank you I will try the quickfix.

Ouput of the command given:

curl 7.51.0 (x86_64-apple-darwin16.0) libcurl/7.51.0 SecureTransport zlib/1.2.8
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz UnixSockets

Updated the output...

OGKevin commented 7 years ago

@SebastiaanKloos I think you left out 1 line. That output should be 3 lines if im not mistaken. The line you left out should look something like this: curl 7.54.0 (x86_64-apple-darwin16.0) libcurl/7.54.0 SecureTransport zlib/1.2.8

SebastiaanKloos commented 7 years ago

@OGKevin fixed it. Edited my answer!

dnl-blkv commented 7 years ago

@SebastiaanKloos When your system makes a request, the request is forwarded from Laravel to curl via curl wrapper. Curl then sends the request to the other server. Then the request goes through the proxies, if any present. The bug we observe happens when the curl is invoked by the curl wrapper. In other words, Laravel is occurring before the issue, and proxies occur after it.

Besides the quick fix @OGKevin suggested, it might help to update your curl version to 7.54.1 with OpenSSL. I believe the error is related to it.

What do you see if you type which curl in the terminal?

SebastiaanKloos commented 7 years ago

@dnl-blkv Thank you for your answer. I will try to update my cURL version.

which curl returns /usr/bin/curl

dnl-blkv commented 7 years ago

@SebastiaanKloos this means you are using the default Curl of Mac which is known to cause issues in various places due to Apple enforcing it to use the SecureTransport backend.

Please consider running this:

brew reinstall curl --with-openssl --with-nghttp2
brew link curl --force
echo 'export PATH="/usr/local/opt/curl/bin:$PATH"' >> ~/.bash_profile

And then please type from a new terminal window first:

which curl

Then:

curl --version

And please copy paste the results here :).

SebastiaanKloos commented 7 years ago

@dnl-blkv Followed the steps:

curl 7.51.0 (x86_64-apple-darwin16.0) libcurl/7.51.0 SecureTransport zlib/1.2.8
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz UnixSockets
dnl-blkv commented 7 years ago

@SebastiaanKloos was it indeed from a new terminal window?

SebastiaanKloos commented 7 years ago

@dnl-blkv you are right on a new window it shows this:

curl 7.54.1 (x86_64-apple-darwin16.6.0) libcurl/7.54.1 OpenSSL/1.0.2l zlib/1.2.8 nghttp2/1.24.0
Release-Date: 2017-06-14
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP HTTP2 UnixSockets HTTPS-proxy

Thank you very much

OGKevin commented 7 years ago

@SebastiaanKloos Is it now working properly for you ?

SebastiaanKloos commented 7 years ago

@OGKevin I restarted the server but it still shows cURL version 7.51 on my phpinfo(). I'll try to find what is causing this issue

dnl-blkv commented 7 years ago

@SebastiaanKloos Is your PHP installed with homebrew?

SebastiaanKloos commented 7 years ago

@dnl-blkv Yes I have installed PHP 7.1 with Homebrew.

dnl-blkv commented 7 years ago

@SebastiaanKloos what may help is:

brew update
brew upgrade
brew reinstall php71 --with-homebrew-curl  --with-homebrew-openssl

Please also keep in mind that if you used any other options earlier when installing the current PHP 7.1, you might want to re-apply them again!

basst85 commented 7 years ago

Also had this error (PHP Notice: Use of undefined constant CURLOPT_PINNEDPUBLICKEY - assumed 'CURLOPT_PINNEDPUBLICKEY' in /var/www/emonkey.nl/bunq/sdk_php/lib/Http/ApiClient.php on line 163)

The @OGKevin work-around fixed it 👍

OGKevin commented 7 years ago

Hey @basst85,

What version of curl are you using ?

basst85 commented 7 years ago

@OGKevin I've updated PHP on my Debian server (to version 7.1.6-2), and cUrl to 7.52.1. It's working fine now without the work-around 👍

OGKevin commented 7 years ago

@basst85 Thats good to hear 😄

jimkaler commented 6 years ago

I am unable to solve this issue while installing vendor\bin\bunq-install
An unexpected error occurred: cURL error 60: SSL certificate problem: unable to get local issuer certificate (see http://curl.haxx.se/libcurl/c/libcurl-errors.html) please help me out.

OGKevin commented 6 years ago

@JimKaler please see #104