xmpp-prebind-php icon indicating copy to clipboard operation
xmpp-prebind-php copied to clipboard

Encryption with Openfire 3.10.3

Open andreabenini opened this issue 8 years ago • 2 comments

Hi there, As told on issue #16 I have had troubles with authentication when using this library, I don't think there's a special setting inside openfire for bosh encryption setup. I have had weird behavior with auth. My php code is just

// Fake proof of concept, just a test but works
ini_set('max_execution_time', 300); //300 seconds = 5 minutes
try {
    require_once("lib/XmppPrebind.php");
    $username = "test";
    $password = "test";
    $jabberHost = "myhost.domain.local";
    $boshUri    = "http://myhost.domain.local:7070/http-bind/";
    $resource   = "resource";
    $xmppPrebind = new XmppPrebind($jabberHost, $boshUri, $resource, false, false);
    $xmppPrebind->connect($username, $password);
    $xmppPrebind->auth();
    var_dump($xmppPrebind->getSessionInfo());
} catch (Exception $e) {
    echo $e->getMessage();
}

I have added a line in your connect() function, I know this is just a weird and dirty hack but works. I don't like it so suggestions are welcomed, Changes:

        if (in_array(self::ENCRYPTION_DIGEST_MD5, $this->mechanisms)) {
            $this->encryption = self::ENCRYPTION_DIGEST_MD5;
        } elseif (in_array(self::ENCRYPTION_CRAM_MD5, $this->mechanisms)) {
            $this->encryption = self::ENCRYPTION_CRAM_MD5;
        } elseif (in_array(self::ENCRYPTION_PLAIN, $this->mechanisms)) {
            $this->encryption = self::ENCRYPTION_PLAIN;
        } else {
            throw new XmppPrebindConnectionException("No encryption supported by the server is supported by this library.");
        }
        $this->encryption = self::ENCRYPTION_PLAIN;
        $this->debug($this->encryption, 'encryption used');

my add is just "$this->encryption = self::ENCRYPTION_PLAIN;". I was thinking about adding a third (optional) parameter on connect() for specifying preferred authentication method, may I submit a pull request for it ?

Ben

andreabenini avatar Nov 24 '15 09:11 andreabenini