Skip to content

Commit 7d99a9c

Browse files
committed
Merge branch 'PHP-8.3'
* PHP-8.3: Fix bug #55639: Digest autentication dont work
2 parents 0caaeb6 + d3caedd commit 7d99a9c

File tree

2 files changed

+70
-5
lines changed

2 files changed

+70
-5
lines changed

ext/soap/php_http.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ int make_http_soap_request(zval *this_ptr,
748748
PHP_MD5Update(&md5ctx, (unsigned char*)":", 1);
749749
PHP_MD5Update(&md5ctx, (unsigned char*)cnonce, 8);
750750
PHP_MD5Update(&md5ctx, (unsigned char*)":", 1);
751-
/* TODO: Support for qop="auth-int" */
751+
/* TODO: Support for qop=auth-int */
752752
PHP_MD5Update(&md5ctx, (unsigned char*)"auth", sizeof("auth")-1);
753753
PHP_MD5Update(&md5ctx, (unsigned char*)":", 1);
754754
}
@@ -784,11 +784,11 @@ int make_http_soap_request(zval *this_ptr,
784784
}
785785
if ((tmp = zend_hash_str_find(Z_ARRVAL_P(digest), "qop", sizeof("qop")-1)) != NULL &&
786786
Z_TYPE_P(tmp) == IS_STRING) {
787-
/* TODO: Support for qop="auth-int" */
788-
smart_str_append_const(&soap_headers, "\", qop=\"auth");
789-
smart_str_append_const(&soap_headers, "\", nc=\"");
787+
/* TODO: Support for qop=auth-int */
788+
smart_str_append_const(&soap_headers, "\", qop=auth");
789+
smart_str_append_const(&soap_headers, ", nc=");
790790
smart_str_appendl(&soap_headers, nc, 8);
791-
smart_str_append_const(&soap_headers, "\", cnonce=\"");
791+
smart_str_append_const(&soap_headers, ", cnonce=\"");
792792
smart_str_appendl(&soap_headers, cnonce, 8);
793793
}
794794
smart_str_append_const(&soap_headers, "\", response=\"");

ext/soap/tests/bugs/bug55639.phpt

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
--TEST--
2+
Bug #55639 (Digest authentication dont work)
3+
--INI--
4+
soap.wsdl_cache_enabled=0
5+
--EXTENSIONS--
6+
soap
7+
--SKIPIF--
8+
<?php
9+
if (!file_exists(__DIR__ . "/../../../../sapi/cli/tests/php_cli_server.inc")) {
10+
echo "skip sapi/cli/tests/php_cli_server.inc required but not found";
11+
}
12+
?>
13+
--FILE--
14+
<?php
15+
16+
include __DIR__ . "/../../../../sapi/cli/tests/php_cli_server.inc";
17+
18+
$args = ["-d", "extension_dir=" . ini_get("extension_dir"), "-d", "extension=" . (substr(PHP_OS, 0, 3) == "WIN" ? "php_" : "") . "soap." . PHP_SHLIB_SUFFIX];
19+
if (php_ini_loaded_file()) {
20+
// Necessary such that it works from a development directory in which case extension_dir might not be the real extension dir
21+
$args[] = "-c";
22+
$args[] = php_ini_loaded_file();
23+
}
24+
25+
$code = <<<'PHP'
26+
/* Receive */
27+
header('HTTP/1.0 401 Unauthorized');
28+
header('WWW-Authenticate: Digest realm="realm", qop="auth,auth-int", nonce="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", opaque="bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"');
29+
file_get_contents("php://input");
30+
PHP;
31+
32+
php_cli_server_start($code, null, $args);
33+
34+
$client = new soapclient(NULL, [
35+
'location' => 'http://' . PHP_CLI_SERVER_ADDRESS,
36+
'uri' => 'misc-uri',
37+
'authentication' => SOAP_AUTHENTICATION_DIGEST,
38+
'realm' => 'myrealm',
39+
'login' => 'user',
40+
'password' => 'pass',
41+
'trace' => true,
42+
]);
43+
44+
try {
45+
$client->__soapCall("foo", []);
46+
} catch (Throwable $e) {
47+
echo $e->getMessage(), "\n";
48+
}
49+
50+
$headers = $client->__getLastRequestHeaders();
51+
var_dump($headers);
52+
53+
?>
54+
--EXPECTF--
55+
Unauthorized
56+
string(%d) "POST / HTTP/1.1
57+
Host: %s
58+
Connection: Keep-Alive
59+
User-Agent: %s
60+
Content-Type: text/xml; charset=utf-8
61+
SOAPAction: "misc-uri#foo"
62+
Content-Length: %d
63+
Authorization: Digest username="user", realm="realm", nonce="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", uri="/", qop=auth, nc=00000001, cnonce="%s", response="%s", opaque="bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
64+
65+
"

0 commit comments

Comments
 (0)