Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new-lib: FileAdapter and SSL issue #87

Closed
zimbatm opened this issue Jan 13, 2016 · 10 comments
Closed

new-lib: FileAdapter and SSL issue #87

zimbatm opened this issue Jan 13, 2016 · 10 comments

Comments

@zimbatm
Copy link
Contributor

zimbatm commented Jan 13, 2016

make test returns the following error on my system:

1) Pusher\Tests\FileAdapterTest::testRequest
Notice: Undefined index: _SERVER in /Users/zimbatm/code/github.com/pusher/pusher-http-php/vendor/phpunit/phpunit/src/Util/Filter.php on line 28
Pusher\Exception\AdapterException: file_get_contents(https://pusher.com): failed to open stream: operation failed

/Users/zimbatm/code/github.com/pusher/pusher-http-php/src/Http/FileAdapter.php:73
/Users/zimbatm/code/github.com/pusher/pusher-http-php/tests/FileAdapterTest.php:38
/Users/zimbatm/code/github.com/pusher/pusher-http-php/vendor/phpunit/phpunit/phpunit:36

However SSL seem to be enabled and stream_get_contents() to support including remote files:

$ php -a
Interactive shell

php > var_dump(stream_get_wrappers());
array(12) {
  [0]=>
  string(5) "https"
  [1]=>
  string(4) "ftps"
  [2]=>
  string(13) "compress.zlib"
  [3]=>
  string(14) "compress.bzip2"
  [4]=>
  string(3) "php"
  [5]=>
  string(4) "file"
  [6]=>
  string(4) "glob"
  [7]=>
  string(4) "data"
  [8]=>
  string(4) "http"
  [9]=>
  string(3) "ftp"
  [10]=>
  string(4) "phar"
  [11]=>
  string(3) "zip"
}
php > var_dump(ini_get('allow_url_fopen'));
string(1) "1"
php > var_dump(extension_loaded('openssl'));
bool(true)

If I change the test domain to be google.com or github.com I get the same error.
Changing to plain HTTP doesn't have the same issue.

@GrahamCampbell
Copy link
Contributor

What php version?

@GrahamCampbell
Copy link
Contributor

Having the cacert.pem file in the code base is a bad practice btw.

@zimbatm
Copy link
Contributor Author

zimbatm commented Jan 13, 2016

$ php -v
PHP 5.5.30 (cli) (built: Oct 23 2015 17:21:45)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies

What is the best practice in regards to cacert.pem ? I know that PHP 5.6 is able to find the system CA certs but what to do with older versions ? I've been looking at Guzzle quite a lot and here is what they do: https://github.com/guzzle/guzzle/blob/master/src/Handler/StreamHandler.php#L352-L353

@zimbatm
Copy link
Contributor Author

zimbatm commented Jan 13, 2016

Btw if you have any ideas on how to improve the new-lib I'm all ears, I don't qualify as a PHP veteran at all.

@GrahamCampbell
Copy link
Contributor

TBH, I'd actually recommend just using guzzle 5/6 and dropping php 5.3 support, but keeping php 5.4 support. Then you don't need to worry about any of this http stuff. Guzzle will do it all for us.

@GrahamCampbell
Copy link
Contributor

NB, requiring guzzle ^5.0|^6.0 will allow either version to be resolved for maximum compatibility.

@GrahamCampbell
Copy link
Contributor

Also note that guzzle 3 can be installed along side guzzle 4+ because it's technically a different package in a different namesace, so conflicts with older libraries shouldn't be a problem either.

@zimbatm
Copy link
Contributor Author

zimbatm commented Jan 13, 2016

It's tempting to use guzzle but it also introduces a lot of unnecessary complexity. My hope was to keep this library small and not add too much dependencies.

@GrahamCampbell
Copy link
Contributor

Guzzle is small imo, and definitely makes this library smaller and simpler.

@kn100
Copy link
Contributor

kn100 commented Nov 16, 2017

Closed in preference to #95

@kn100 kn100 closed this as completed Nov 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants