Skip to content

Commit 7e7821b

Browse files
committed
add: skip hostname checks if CURLRequest options 'verify' is set to false.
When CURLRequest options 'verify' is set to false, some CURLOPT_SSL_... options should be disabled in such a way as to allow requests to pass through in case the destination is for example on private networks. Avoids SSL errors: SSL: certificate subject name 'CA' does not match target host name 'localhost'
1 parent 99c1a4b commit 7e7821b

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

system/HTTP/CURLRequest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,12 @@ protected function setCURLOptions(array $curlOptions = [], array $config = [])
559559
$curlOptions[CURLOPT_SSL_VERIFYPEER] = 1;
560560
} elseif (is_bool($config['verify'])) {
561561
$curlOptions[CURLOPT_SSL_VERIFYPEER] = $config['verify'];
562+
563+
if ($config['verify'] === false) {
564+
$curlOptions[CURLOPT_SSL_VERIFYHOST] = 0;
565+
} else {
566+
$curlOptions[CURLOPT_SSL_VERIFYHOST] = 2;
567+
}
562568
}
563569
}
564570

tests/system/HTTP/CURLRequestTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,9 @@ public function testSSLVerification(): void
529529

530530
$this->assertArrayHasKey(CURLOPT_SSL_VERIFYPEER, $options);
531531
$this->assertSame(1, $options[CURLOPT_SSL_VERIFYPEER]);
532+
533+
$this->assertArrayHasKey(CURLOPT_SSL_VERIFYHOST, $options);
534+
$this->assertSame(2, $options[CURLOPT_SSL_VERIFYHOST]);
532535
}
533536

534537
public function testSSLWithBadKey(): void

0 commit comments

Comments
 (0)