Skip to content

Commit 0a32b24

Browse files
committed
Eliminated 'ssl_key' and adjusted for ['verify'] boolean or file path
1 parent ee1718f commit 0a32b24

File tree

3 files changed

+18
-22
lines changed

3 files changed

+18
-22
lines changed

system/HTTP/CURLRequest.php

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -548,24 +548,21 @@ protected function setCURLOptions(array $curlOptions = [], array $config = [])
548548

549549
// SSL Verification
550550
if (isset($config['verify'])) {
551-
if (is_string($config['verify'])) {
552-
$file = realpath($config['ssl_key']) ?: $config['ssl_key'];
551+
$config_verify = $config['verify'];
552+
553+
if (is_string($config_verify)) {
554+
$file = realpath($config_verify) ?: $config_verify;
553555

554556
if (! is_file($file)) {
555-
throw HTTPException::forInvalidSSLKey($config['ssl_key']);
557+
throw HTTPException::forInvalidSSLKey($config_verify);
556558
}
557559

558-
$curlOptions[CURLOPT_CAINFO] = $file;
559-
if ($config['verify'] === 'yes') {
560-
$curlOptions[CURLOPT_SSL_VERIFYPEER] = true;
561-
$curlOptions[CURLOPT_SSL_VERIFYHOST] = 2;
562-
} else {
563-
$curlOptions[CURLOPT_SSL_VERIFYPEER] = false;
564-
$curlOptions[CURLOPT_SSL_VERIFYHOST] = 0;
565-
}
566-
} elseif (is_bool($config['verify'])) {
567-
$curlOptions[CURLOPT_SSL_VERIFYPEER] = $config['verify'];
568-
$curlOptions[CURLOPT_SSL_VERIFYHOST] = $config['verify'] ? 2 : 0;
560+
$curlOptions[CURLOPT_CAINFO] = $file;
561+
$curlOptions[CURLOPT_SSL_VERIFYPEER] = true;
562+
$curlOptions[CURLOPT_SSL_VERIFYHOST] = 2;
563+
} elseif (is_bool($config_verify)) {
564+
$curlOptions[CURLOPT_SSL_VERIFYPEER] = $config_verify;
565+
$curlOptions[CURLOPT_SSL_VERIFYHOST] = $config_verify ? 2 : 0;
569566
}
570567
}
571568

tests/system/HTTP/CURLRequestDoNotShareOptionsTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -535,8 +535,7 @@ public function testSSLVerification(): void
535535
$file = __FILE__;
536536

537537
$this->request->request('get', 'http://example.com', [
538-
'verify' => 'yes',
539-
'ssl_key' => $file,
538+
'verify' => $file,
540539
]);
541540

542541
$options = $this->request->curl_options;
@@ -546,6 +545,9 @@ public function testSSLVerification(): void
546545

547546
$this->assertArrayHasKey(CURLOPT_SSL_VERIFYPEER, $options);
548547
$this->assertTrue($options[CURLOPT_SSL_VERIFYPEER]);
548+
549+
$this->assertArrayHasKey(CURLOPT_SSL_VERIFYHOST, $options);
550+
$this->assertSame(2, $options[CURLOPT_SSL_VERIFYHOST]);
549551
}
550552

551553
public function testSSLWithBadKey(): void
@@ -554,8 +556,7 @@ public function testSSLWithBadKey(): void
554556
$this->expectException(HTTPException::class);
555557

556558
$this->request->request('get', 'http://example.com', [
557-
'verify' => 'yes',
558-
'ssl_key' => $file,
559+
'verify' => $file,
559560
]);
560561
}
561562

tests/system/HTTP/CURLRequestTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -518,8 +518,7 @@ public function testSSLVerification(): void
518518
$file = __FILE__;
519519

520520
$this->request->request('get', 'http://example.com', [
521-
'verify' => 'yes',
522-
'ssl_key' => $file,
521+
'verify' => $file,
523522
]);
524523

525524
$options = $this->request->curl_options;
@@ -555,8 +554,7 @@ public function testSSLWithBadKey(): void
555554
$this->expectException(HTTPException::class);
556555

557556
$this->request->request('get', 'http://example.com', [
558-
'verify' => 'yes',
559-
'ssl_key' => $file,
557+
'verify' => $file,
560558
]);
561559
}
562560

0 commit comments

Comments
 (0)