0

iveは私のxmppサーバーとしてejabberdを取得しました、そしてここに私のphpコードがあります:

$stripped = strip_tags($returnTwo); // remove the xml tags from the response stanza
$decoded = base64_decode($stripped); // decode the jibberish
$regex = "([0-9]{8,})"; // create regex to extract the nonce
preg_match($regex, $decoded, $noncearr); // extracts nonce
$nonce = $noncearr[0]; // finally, we can put the nonce into a variable to continue...

//   1. Create a string of the form "username:realm:password". Call this string X.
$x = "username:server.dyndns.org:password";
//   2. Compute the 16 octet MD5 hash of X. Call the result Y.
$y = md5($x);
//   3. Create a string of the form "Y:nonce:cnonce:authzid". Call this string A1.
$a = "$y:$nonce:$cnonce:username@server.dyndns.org/webchat";
//   4. Create a string of the form "AUTHENTICATE:digest-uri". Call this string A2.
$a2 = "AUTHENTICATE:xmpp/server.dyndns.org";
//   5. Compute the 32 hex digit MD5 hash of A1. Call the result HA1.
$ha1 = md5($a1);
//   6. Compute the 32 hex digit MD5 hash of A2. Call the result HA2.
$ha2 = md5($a2);
//   7. Create a string of the form "HA1:nonce:nc:cnonce:qop:HA2". Call this string KD.
$kd = "$ha1:$nonce:00000001:$cnonce:auth:$ha2";
//   8. Compute the 32 hex digit MD5 hash of KD. Call the result Z.
$z = md5($kd);
$b64z = base64_encode($z);
$respond = "<response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>$b64z</response>";

// initialize curl again
$sendThree = curl_init("http://localhost:5280/http-bind");
curl_setopt($sendThree, CURLOPT_POST, 1);
curl_setopt($sendThree, CURLOPT_POSTFIELDS, $respond);
$returnThree = curl_exec($sendThree);
curl_close($sendThree); // close the curl connection

私の問題は、サーバーが「1」を返すことです。それはそれです、受け入れなし、エラーなし、ただ数1。これの前のステップはすべて期待されたものを返しました、しかしこの部分は問題を抱えています。phpを初めて使用する場合(これは、phpを使用して作成された2番目のページのみになります)、SASLの手順を正しく実行したのか、それともejabberdに問題があるのか​​疑問に思っていますか?

4

4 に答える 4

0

わかりました、私は問題を理解しました:私は自分のridをインクリメントするのを忘れていました... DOI!

それでも満足のいく年寄り..... 今、私は悪いプロトコルエラーを受け取ります x(

于 2010-09-09T21:54:18.747 に答える
0

DIGEST-MD5 auth でまだ問題が発生している場合は、JAXL XMPP Auth クラスを確認することをお勧めします。 #L86

于 2010-09-09T00:25:56.747 に答える
0

curl_exec成功したかどうかに応じてブール値を返します。したがって、関数は を返しtrue、これは数字の 1 にキャストされます。

実際の結果を得るには、次の行を追加する必要があります。

curl_setopt($sendThree, CURLOPT_RETURNTRANSFER, true);
于 2010-09-08T23:58:35.143 に答える
0

コードを確認してください。string $ha1 = md5($a1); があります。"1" なしで $a 変数のみ。

于 2010-10-17T16:37:54.397 に答える