projects/aports·blob master · refs

85 lines · 3.4 KiB

1Patch-Source: https://github.com/php/php-src/pull/21518
2From e5f3237707ab6854885f556012be6eb13eeb7f7e Mon Sep 17 00:00:00 2001
3From: Shivam Mathur <[email protected]>
4Date: Wed, 25 Mar 2026 14:14:41 +0530
5Subject: [PATCH] Fix curl_setopt_ssl test for curl 8.19.0
6
7---
8 ext/curl/tests/curl_setopt_ssl.phpt | 19 ++++++++++---------
9 1 file changed, 10 insertions(+), 9 deletions(-)
10
11diff --git a/ext/curl/tests/curl_setopt_ssl.phpt b/ext/curl/tests/curl_setopt_ssl.phpt
12index ff08528321a0f..e3b97a3ea7326 100644
13--- a/ext/curl/tests/curl_setopt_ssl.phpt
14+++ b/ext/curl/tests/curl_setopt_ssl.phpt
15@@ -37,6 +37,7 @@ function check_response($response, $clientCertSubject) {
16 }
17
18 $clientCertSubject = "Subject: C=US, ST=TX, L=Clientlocation, O=Clientcompany, CN=clientname/[email protected]";
19+$rejectsZeroLengthBlobs = curl_version()['version_number'] >= 0x081300;
20
21 // load server cert
22 $serverCertPath = __DIR__ . DIRECTORY_SEPARATOR . 'curl_setopt_ssl_servercert.pem';
23@@ -91,7 +92,7 @@ try {
24 echo "\n";
25 echo "case 2: empty client cert and key from string\n";
26 $ch = curl_init("https://127.0.0.1:$port/");
27- var_dump(curl_setopt($ch, CURLOPT_SSLCERT_BLOB, ''));
28+ var_dump(curl_setopt($ch, CURLOPT_SSLCERT_BLOB, '') === !$rejectsZeroLengthBlobs);
29 var_dump(curl_setopt($ch, CURLOPT_SSLKEY_BLOB, $clientKey));
30 var_dump(curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false));
31 var_dump(curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false));
32@@ -99,14 +100,14 @@ try {
33
34 $response = curl_exec($ch);
35 check_response($response, $clientCertSubject);
36- check_error($ch);
37+ check_error($ch, $rejectsZeroLengthBlobs ? 56 : 58);
38 curl_close($ch);
39
40 echo "\n";
41 echo "case 3: client cert and empty key from string\n";
42 $ch = curl_init("https://127.0.0.1:$port/");
43 var_dump(curl_setopt($ch, CURLOPT_SSLCERT_BLOB, $clientCert));
44- var_dump(curl_setopt($ch, CURLOPT_SSLKEY_BLOB, ''));
45+ var_dump(curl_setopt($ch, CURLOPT_SSLKEY_BLOB, '') === !$rejectsZeroLengthBlobs);
46 var_dump(curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false));
47 var_dump(curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false));
48 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
49@@ -166,7 +167,7 @@ try {
50 echo "case 7: empty issuer cert from string\n";
51 $ch = curl_init("https://127.0.0.1:$port/");
52 var_dump(curl_setopt($ch, CURLOPT_CAINFO, $serverCertPath));
53- var_dump(curl_setopt($ch, CURLOPT_ISSUERCERT_BLOB, ''));
54+ var_dump(curl_setopt($ch, CURLOPT_ISSUERCERT_BLOB, '') === !$rejectsZeroLengthBlobs);
55 var_dump(curl_setopt($ch, CURLOPT_SSLCERT, $clientCertPath));
56 var_dump(curl_setopt($ch, CURLOPT_SSLKEY, $clientKeyPath));
57 var_dump(curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true));
58@@ -174,8 +175,8 @@ try {
59 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
60
61 $response = curl_exec($ch);
62- check_response($response, $clientCertSubject);
63- check_error($ch);
64+ var_dump((is_string($response) && strpos($response, $clientCertSubject) !== false) === $rejectsZeroLengthBlobs);
65+ var_dump(curl_errno($ch) === ($rejectsZeroLengthBlobs ? 0 : 83));
66 curl_close($ch);
67
68 } finally {
69@@ -199,7 +200,7 @@ bool(true)
70 bool(true)
71 bool(true)
72 client cert subject not in response
73-CURL ERROR: 58
74+CURL ERROR: EXPECTED
75
76 case 3: client cert and empty key from string
77 bool(true)
78@@ -241,5 +242,5 @@ bool(true)
79 bool(true)
80 bool(true)
81 bool(true)
82-client cert subject not in response
83-CURL ERROR: 83
84+bool(true)
85+bool(true)