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

SSL issue under PHP 5.6 #15

Closed
tigerduck42 opened this issue Aug 6, 2015 · 4 comments
Closed

SSL issue under PHP 5.6 #15

tigerduck42 opened this issue Aug 6, 2015 · 4 comments
Assignees

Comments

@tigerduck42
Copy link

The API breaks under PHP 5.6.
This is due to the new verify-by-default policy in PHP 5.6. (See http://stackoverflow.com/questions/27088982/warning-stream-socket-enable-crypto-ssl-operation-failed-with-code-1)

On way to fix is is to add the follwing ssl section to the stream_context_create function.

$streamContext = stream_context_create(array(
  'http' => array(
    'method'  => 'POST',
    'header'  => 'Content-type: application/json-rpc'."\r\n".$this->extraHeaders,
    'content' => $this->requestEncoded
  ),
  'ssl' => array(
    'verify_peer'       => FALSE,
    'verify_peer_name'  => FALSE,
 )
));

in ZabbixApiAbstract::request() (~ line 308)

@domibarton
Copy link
Member

Hi

Sorry for the delay, was quite busy ;)

This isn't really an issue, because your SSL configuration isn't properly configured. But I've implemented a workaround in the 2.2 and 2.4 branches. Can you test the new libraries from one of those branches and give me some feedback?

When you're connecting to the API, make sure you've set the $verifyPeer argument to FALSE:

public function __construct($apiUrl='', $user='', $password='', $httpUser='', $httpPassword='', $authId='', $verifyPeer=TRUE)

Would be great to get some feedback, so I can tag the changes and create a new release.

Cheers
Domi

@domibarton domibarton self-assigned this Oct 2, 2015
domibarton added a commit that referenced this issue Oct 2, 2015
domibarton added a commit that referenced this issue Oct 2, 2015
tigerduck42 pushed a commit to tigerduck42/PhpZabbixApi that referenced this issue Oct 5, 2015
# By Dominique Barton
# Via Dominique Barton
* '2.4' of https://github.com/confirm/PhpZabbixApi:
  new library built
  added peer verification flag to constructor
  better fix for issue confirm#15
  added SSL verify peer flag for issue confirm#15

Conflicts:
	build/ZabbixApiAbstract.class.php
@tigerduck42
Copy link
Author

Almost working :)

You need to move the

 $this->setVerifyPeer($verifyPeer);

call up as the first statement in your constructor.

the method userLogin() uses the method request() which needs the verify peer flag already set the right way.
After this change it is working :-)

@domibarton
Copy link
Member

@tigerduck42 oh stupid me... you're right.
I fixed it in the latest 2.2 and 2.4 dev branches... can you test it and give me a feedback? I no longer use the API myself... ;)

@tigerduck42
Copy link
Author

Perfect!
Working as expected :-)
Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants