Skip to content

Commit 3b85d09

Browse files
committed
Notice if CURLOPT_SSL_VERIFYHOST is set to true
1 parent 7b4a53e commit 3b85d09

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

ext/curl/interface.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2014,6 +2014,10 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu
20142014

20152015
switch (option) {
20162016
/* Long options */
2017+
case CURLOPT_SSL_VERIFYHOST:
2018+
if(Z_TYPE_PP(zvalue)==IS_BOOL && Z_BVAL_PP(zvalue)) {
2019+
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "CURLOPT_SSL_VERIFYHOST set to true which disables common name validation (setting CURLOPT_SSL_VERIFYHOST to 2 enables common name validation)");
2020+
}
20172021
case CURLOPT_AUTOREFERER:
20182022
case CURLOPT_BUFFERSIZE:
20192023
case CURLOPT_CLOSEPOLICY:
@@ -2048,7 +2052,6 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu
20482052
case CURLOPT_PUT:
20492053
case CURLOPT_RESUME_FROM:
20502054
case CURLOPT_SSLVERSION:
2051-
case CURLOPT_SSL_VERIFYHOST:
20522055
case CURLOPT_SSL_VERIFYPEER:
20532056
case CURLOPT_TIMECONDITION:
20542057
case CURLOPT_TIMEOUT:

ext/curl/tests/bug63363.phpt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
--TEST--
2+
Bug #63363 (CURL silently accepts boolean value for SSL_VERIFYHOST)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded("curl")) {
6+
exit("skip curl extension not loaded");
7+
}
8+
9+
?>
10+
--FILE--
11+
<?php
12+
$ch = curl_init();
13+
var_dump(curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false));
14+
/* Case that should throw an error */
15+
var_dump(curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, true));
16+
var_dump(curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0));
17+
var_dump(curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1));
18+
var_dump(curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2));
19+
20+
curl_close($ch);
21+
?>
22+
--EXPECTF--
23+
bool(true)
24+
25+
Notice: curl_setopt(): CURLOPT_SSL_VERIFYHOST set to true which disables common name validation (setting CURLOPT_SSL_VERIFYHOST to 2 enables common name validation) in %s on line %d
26+
bool(true)
27+
bool(true)
28+
bool(true)
29+
bool(true)

0 commit comments

Comments
 (0)