confirm/PhpZabbixApi

SSL issue under PHP 5.6

tigerduck42 opened this issue · 4 comments

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)

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

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 :-)

@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... ;)

Perfect!
Working as expected :-)
Thank you.