Skip to content

Commit 6f3bc59

Browse files
Ayeshbukka
authored andcommitted
ext/curl: Add CURLOPT_SSL_SIGNATURE_ALGORITHMS option
Adds support for `CURLOPT_SSL_SIGNATURE_ALGORITHMS`[^1], supported since Curl version 8.14.0. [^1]: https://curl.se/libcurl/c/CURLOPT_SSL_SIGNATURE_ALGORITHMS.html Closes GH-18692
1 parent 73b1ebf commit 6f3bc59

File tree

7 files changed

+64
-1
lines changed

7 files changed

+64
-1
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ PHP NEWS
1010
- Curl:
1111
. Add support for CURLINFO_CONN_ID in curl_getinfo() (thecaliskan)
1212
. Add support for CURLINFO_QUEUE_TIME_T in curl_getinfo() (thecaliskan)
13+
. Add support for CURLOPT_SSL_SIGNATURE_ALGORITHMS. (Ayesh Karunaratne)
1314

1415
- OPcache:
1516
. Disallow changing opcache.memory_consumption when SHM is already set up.

UPGRADING

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@ PHP 8.5 UPGRADE NOTES
198198
request spent in libcurl’s connection queue before it was sent.
199199
This value can also be retrieved by passing CURLINFO_QUEUE_TIME_T to the
200200
curl_getinfo() $option parameter.
201+
. Added support for CURLOPT_SSL_SIGNATURE_ALGORITHMS to specify the signature
202+
algorithms to use for TLS.
201203

202204
- DOM:
203205
. Added Dom\Element::$outerHTML.

ext/curl/curl.stub.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3339,6 +3339,13 @@
33393339
* @cvalue CURLOPT_SSL_EC_CURVES
33403340
*/
33413341
const CURLOPT_SSL_EC_CURVES = UNKNOWN;
3342+
#if LIBCURL_VERSION_NUM >= 0x080e00 /* Available since 8.14.0 */
3343+
/**
3344+
* @var int
3345+
* @cvalue CURLOPT_SSL_SIGNATURE_ALGORITHMS
3346+
*/
3347+
const CURLOPT_SSL_SIGNATURE_ALGORITHMS = UNKNOWN;
3348+
#endif
33423349
/**
33433350
* @var int
33443351
* @cvalue CURLPX_BAD_ADDRESS_TYPE

ext/curl/curl_arginfo.h

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/curl/interface.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1944,6 +1944,9 @@ static zend_result _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue
19441944
case CURLOPT_USERPWD:
19451945
case CURLOPT_USERNAME:
19461946
case CURLOPT_PASSWORD:
1947+
#if LIBCURL_VERSION_NUM >= 0x080e00 /* Available since 8.14.0 */
1948+
case CURLOPT_SSL_SIGNATURE_ALGORITHMS:
1949+
#endif
19471950
{
19481951
if (Z_ISNULL_P(zvalue)) {
19491952
error = curl_easy_setopt(ch->cp, option, NULL);

ext/curl/tests/Caddyfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,8 @@ basic_auth /http-basic-auth {
2121
# bcrypt password hash for "password", calculated with 'caddy hash-password'
2222
user $2a$14$yUKl9SGqVTAAqPTzLup.DefsbXXx3kfreNnzpJOUHcIrKnr5lgef2
2323
}
24+
25+
route /ping {
26+
templates
27+
respond `pong`
28+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
--TEST--
2+
Curl option CURLOPT_SSL_SIGNATURE_ALGORITHMS
3+
--EXTENSIONS--
4+
curl
5+
--SKIPIF--
6+
<?php
7+
$curl_version = curl_version();
8+
if ($curl_version['version_number'] < 0x080e00) die("skip: test works only with curl >= 8.14.0");
9+
10+
include 'skipif-nocaddy.inc';
11+
?>
12+
--FILE--
13+
<?php
14+
15+
$ch = curl_init('https://localhost/ping');
16+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
17+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
18+
19+
var_dump(curl_exec($ch));
20+
21+
var_dump(curl_setopt($ch, CURLOPT_SSL_SIGNATURE_ALGORITHMS, 'invalid-value'));
22+
var_dump(curl_exec($ch));
23+
var_dump(curl_error($ch));
24+
25+
var_dump(curl_setopt($ch, CURLOPT_SSL_SIGNATURE_ALGORITHMS, 'ECDSA+SHA256:RSA+SHA256:DSA+SHA256:ed25519'));
26+
var_dump(curl_exec($ch));
27+
28+
var_dump(curl_setopt($ch, CURLOPT_SSL_SIGNATURE_ALGORITHMS, null));
29+
var_dump(curl_exec($ch));
30+
31+
?>
32+
--EXPECT--
33+
string(4) "pong"
34+
bool(true)
35+
bool(false)
36+
string(52) "failed setting signature algorithms: 'invalid-value'"
37+
bool(true)
38+
string(4) "pong"
39+
bool(true)
40+
string(4) "pong"

0 commit comments

Comments
 (0)