Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
GrahamCampbell committed May 13, 2023
1 parent bda23aa commit 38b9f45
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/Handler/CurlFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -455,26 +455,26 @@ private function applyHandlerOptions(EasyHandle $easy, array &$conf): void
if (isset($options['crypto_method'])) {
if (\STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT === $options['crypto_method']) {
if (!defined('CURL_SSLVERSION_TLSv1_0')) {
throw new \InvalidArgumentException('Setting `crypto_method` to TLS 1.0 not supported by your version of cURL.');
throw new \InvalidArgumentException('Invalid crypto_method request option: TLS 1.0 not supported by your version of cURL');
}
$conf[\CURLOPT_SSLVERSION] = \CURL_SSLVERSION_TLSv1_0;
} elseif (\STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT === $options['crypto_method']) {
if (!defined('CURL_SSLVERSION_TLSv1_1')) {
throw new \InvalidArgumentException('Setting `crypto_method` to TLS 1.1 not supported by your version of cURL.');
throw new \InvalidArgumentException('Invalid crypto_method request option: TLS 1.1 not supported by your version of cURL');
}
$conf[\CURLOPT_SSLVERSION] = \CURL_SSLVERSION_TLSv1_1;
} elseif (\STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT === $options['crypto_method']) {
if (!defined('CURL_SSLVERSION_TLSv1_2')) {
throw new \InvalidArgumentException('Setting `crypto_method` to TLS 1.2 not supported by your version of cURL.');
throw new \InvalidArgumentException('Invalid crypto_method request option: TLS 1.2 not supported by your version of cURL');
}
$conf[\CURLOPT_SSLVERSION] = \CURL_SSLVERSION_TLSv1_2;
} elseif (defined('STREAM_CRYPTO_METHOD_TLSv1_3_CLIENT') && \STREAM_CRYPTO_METHOD_TLSv1_3_CLIENT === $options['crypto_method']) {
if (!defined('CURL_SSLVERSION_TLSv1_3')) {
throw new \InvalidArgumentException('Setting `crypto_method` to TLS 1.3 not supported by your version of cURL.');
throw new \InvalidArgumentException('Invalid crypto_method request option: TLS 1.3 not supported by your version of cURL');
}
$conf[\CURLOPT_SSLVERSION] = \CURL_SSLVERSION_TLSv1_3;
} else {
throw new \InvalidArgumentException('An invalid `crypto_method` value was supplied.');
throw new \InvalidArgumentException('Invalid crypto_method request option: unknown version provided');
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Handler/StreamHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ private function add_crypto_method(RequestInterface $request, array &$options, $
return;
}

throw new InvalidArgumentException('An invalid `crypto_method` value was supplied.');
throw new \InvalidArgumentException('Invalid crypto_method request option: unknown version provided');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/Handler/CurlFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public function testValidatesCryptoMethodInvalidMethod()
$f = new Handler\CurlFactory(3);

$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('An invalid `crypto_method` value was supplied.');
$this->expectExceptionMessage('Invalid crypto_method request option: unknown version provided');
$f->create(new Psr7\Request('GET', Server::$url), ['crypto_method' => 123]);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Handler/StreamHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ public function testEnsuresVerifyOptionIsValid()
public function testEnsuresCryptoMethodOptionIsValid()
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Invalid verify request option');
$this->expectExceptionMessage('Invalid crypto_method request option: unknown version provided');

$this->getSendResult(['crypto_method' => 123]);
}
Expand Down

0 comments on commit 38b9f45

Please sign in to comment.