Skip to content

Commit 59f9f63

Browse files
committed
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4: Fix curl_setopt_ssl test for curl 8.19.0 (#21518)
2 parents 4b79bbb + cd568cb commit 59f9f63

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

ext/curl/tests/curl_setopt_ssl.phpt

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ function check_response($response, $clientCertSubject) {
3737
}
3838

3939
$clientCertSubject = "Subject: C=US, ST=TX, L=Clientlocation, O=Clientcompany, CN=clientname/emailAddress=test@example.com";
40+
$rejectsZeroLengthBlobs = curl_version()['version_number'] >= 0x081300;
4041

4142
// load server cert
4243
$serverCertPath = __DIR__ . DIRECTORY_SEPARATOR . 'curl_setopt_ssl_servercert.pem';
@@ -91,22 +92,22 @@ try {
9192
echo "\n";
9293
echo "case 2: empty client cert and key from string\n";
9394
$ch = curl_init("https://127.0.0.1:$port/");
94-
var_dump(curl_setopt($ch, CURLOPT_SSLCERT_BLOB, ''));
95+
var_dump(curl_setopt($ch, CURLOPT_SSLCERT_BLOB, '') === !$rejectsZeroLengthBlobs);
9596
var_dump(curl_setopt($ch, CURLOPT_SSLKEY_BLOB, $clientKey));
9697
var_dump(curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false));
9798
var_dump(curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false));
9899
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
99100

100101
$response = curl_exec($ch);
101102
check_response($response, $clientCertSubject);
102-
check_error($ch);
103+
check_error($ch, $rejectsZeroLengthBlobs ? 56 : 58);
103104
$ch = null;
104105

105106
echo "\n";
106107
echo "case 3: client cert and empty key from string\n";
107108
$ch = curl_init("https://127.0.0.1:$port/");
108109
var_dump(curl_setopt($ch, CURLOPT_SSLCERT_BLOB, $clientCert));
109-
var_dump(curl_setopt($ch, CURLOPT_SSLKEY_BLOB, ''));
110+
var_dump(curl_setopt($ch, CURLOPT_SSLKEY_BLOB, '') === !$rejectsZeroLengthBlobs);
110111
var_dump(curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false));
111112
var_dump(curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false));
112113
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
@@ -166,16 +167,16 @@ try {
166167
echo "case 7: empty issuer cert from string\n";
167168
$ch = curl_init("https://127.0.0.1:$port/");
168169
var_dump(curl_setopt($ch, CURLOPT_CAINFO, $serverCertPath));
169-
var_dump(curl_setopt($ch, CURLOPT_ISSUERCERT_BLOB, ''));
170+
var_dump(curl_setopt($ch, CURLOPT_ISSUERCERT_BLOB, '') === !$rejectsZeroLengthBlobs);
170171
var_dump(curl_setopt($ch, CURLOPT_SSLCERT, $clientCertPath));
171172
var_dump(curl_setopt($ch, CURLOPT_SSLKEY, $clientKeyPath));
172173
var_dump(curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true));
173174
var_dump(curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false));
174175
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
175176

176177
$response = curl_exec($ch);
177-
check_response($response, $clientCertSubject);
178-
check_error($ch);
178+
var_dump((is_string($response) && strpos($response, $clientCertSubject) !== false) === $rejectsZeroLengthBlobs);
179+
var_dump(curl_errno($ch) === ($rejectsZeroLengthBlobs ? 0 : 83));
179180
$ch = null;
180181

181182
} finally {
@@ -199,7 +200,7 @@ bool(true)
199200
bool(true)
200201
bool(true)
201202
client cert subject not in response
202-
CURL ERROR: 58
203+
CURL ERROR: EXPECTED
203204

204205
case 3: client cert and empty key from string
205206
bool(true)
@@ -241,5 +242,5 @@ bool(true)
241242
bool(true)
242243
bool(true)
243244
bool(true)
244-
client cert subject not in response
245-
CURL ERROR: 83
245+
bool(true)
246+
bool(true)

0 commit comments

Comments
 (0)