Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfa841e4

Browse files
[HttpClient] Add optioncrypto_method to set the minimum SSL version and make it default to TLSv1.2
1 parent6222f8e commitfa841e4

File tree

9 files changed

+32
-1
lines changed

9 files changed

+32
-1
lines changed

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1849,6 +1849,9 @@ private function addHttpClientSection(ArrayNodeDefinition $rootNode, callable $e
18491849
->variableNode('md5')->end()
18501850
->end()
18511851
->end()
1852+
->scalarNode('crypto_method')
1853+
->info('The minimum version of SSL to accept; must be one of STREAM_CRYPTO_METHOD_TLSv*_CLIENT constants.')
1854+
->end()
18521855
->arrayNode('extra')
18531856
->info('Extra options for specific HTTP client')
18541857
->normalizeKeys(false)

‎src/Symfony/Component/HttpClient/CHANGELOG.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
6.4
5+
---
6+
7+
* Add option`crypto_method` to set the minimum SSL version and make it default to TLSv1.2
8+
49
6.3
510
---
611

‎src/Symfony/Component/HttpClient/CurlHttpClient.php‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@ public function request(string $method, string $url, array $options = []): Respo
116116
\CURLOPT_SSLKEY =>$options['local_pk'],
117117
\CURLOPT_KEYPASSWD =>$options['passphrase'],
118118
\CURLOPT_CERTINFO =>$options['capture_peer_cert_chain'],
119+
\CURLOPT_SSLVERSION =>match ($options['crypto_method']) {
120+
\STREAM_CRYPTO_METHOD_TLSv1_3_CLIENT => \CURL_SSLVERSION_TLSv1_3,
121+
\STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT => \CURL_SSLVERSION_TLSv1_2,
122+
\STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT => \CURL_SSLVERSION_TLSv1_1,
123+
\STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT => \CURL_SSLVERSION_TLSv1_0,
124+
}
119125
];
120126

121127
if (1.0 === (float)$options['http_version']) {

‎src/Symfony/Component/HttpClient/HttpClientTrait.php‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,15 @@ private static function prepareRequest(?string $method, ?string $url, array $opt
116116
$options['peer_fingerprint'] =self::normalizePeerFingerprint($options['peer_fingerprint']);
117117
}
118118

119+
if (isset($options['crypto_method']) && !\in_array($options['crypto_method'], [
120+
\STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT,
121+
\STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT,
122+
\STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT,
123+
\STREAM_CRYPTO_METHOD_TLSv1_3_CLIENT,
124+
],true)) {
125+
thrownewInvalidArgumentException('Option "crypto_method" must be one of "STREAM_CRYPTO_METHOD_TLSv1_*_CLIENT".');
126+
}
127+
119128
// Validate on_progress
120129
if (isset($options['on_progress']) && !\is_callable($onProgress =$options['on_progress'])) {
121130
thrownewInvalidArgumentException(sprintf('Option "on_progress" must be callable, "%s" given.',get_debug_type($onProgress)));

‎src/Symfony/Component/HttpClient/Internal/AmpClientState.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ private function getClient(array $options): array
141141
$options['local_cert'] &&$context =$context->withCertificate(newCertificate($options['local_cert'],$options['local_pk']));
142142
$options['ciphers'] &&$context =$context->withCiphers($options['ciphers']);
143143
$options['capture_peer_cert_chain'] &&$context =$context->withPeerCapturing();
144+
$options['crypto_method'] &&$context =$context->withMinimumVersion($options['crypto_method']);
144145

145146
$connector =$handleConnector =newclass()implements Connector {
146147
public$connector;

‎src/Symfony/Component/HttpClient/NativeHttpClient.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ public function request(string $method, string $url, array $options = []): Respo
215215
'verify_peer_name' =>$options['verify_host'],
216216
'cafile' =>$options['cafile'],
217217
'capath' =>$options['capath'],
218+
'crypto_method' =>$options['crypto_method'],
218219
'local_cert' =>$options['local_cert'],
219220
'local_pk' =>$options['local_pk'],
220221
'passphrase' =>$options['passphrase'],

‎src/Symfony/Component/HttpClient/composer.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"php":">=8.1",
2626
"psr/log":"^1|^2|^3",
2727
"symfony/deprecation-contracts":"^2.5|^3",
28-
"symfony/http-client-contracts":"^3",
28+
"symfony/http-client-contracts":"^3.3",
2929
"symfony/service-contracts":"^2.5|^3"
3030
},
3131
"require-dev": {

‎src/Symfony/Contracts/CHANGELOG.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
3.3
5+
---
6+
7+
* Add option`crypto_method` to`HttpClientInterface` to define the minimum SSL version to accept
8+
49
3.2
510
---
611

‎src/Symfony/Contracts/HttpClient/HttpClientInterface.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ interface HttpClientInterface
6666
'ciphers' =>null,
6767
'peer_fingerprint' =>null,
6868
'capture_peer_cert_chain' =>false,
69+
'crypto_method' => \STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT,// STREAM_CRYPTO_METHOD_TLSv*_CLIENT - minimum SSL version
6970
'extra' => [],// array - additional options that can be ignored if unsupported, unlike regular options
7071
];
7172

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp