CURLOPT_SSL_VERIFYHOST with value 1 is deprecated

Description

You get the following error when trying to set CURLOPT_SSL_VERIFYHOST*:
ErrorException [ 8 ]: curl_setopt(): CURLOPT_SSL_VERIFYHOST with value 1 is deprecated and will be removed as of libcurl 7.28.1. It is recommended to use value 2 instead ~ APPPATH/whatever.php [ 1761 ]

* i.e. curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 1);

Solution

CURLOPT_SSL_VERIFYHOST value 1 is deprecated and also insecure.
1 = Check the existence of a common name in the SSL peer certificate.
2 = Check the existence of a common name and also verify that it matches the hostname provided.

In short, you should use value 2 instead:
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);

Affected software:

PHP 5.x




Comments:

Comment #1 from codeDebugger [Username: Guest] at 29/10/2014 16:43
Ey, looks like that's wrong. You have to replace the CURLOPT_SSL_VERIFYHOST to 2 instead not the 3rd argument from 1 to 2.

Hence, from
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 1);
becomes
curl_setopt($curl, 2 , 1);
Comment #2 from Kobi Shmueli [Username: Kobi_S] at 02/12/2014 03:38
codeDebugger: That's incorrect.

The syntax is: curl_setopt ( resource $ch , int $option , mixed $value )

CURLOPT_SSL_VERIFYHOST is the option and 2 is the value for that option.

-Kobi.


Add new comment
Name:
Anti-Bots verification code (just write 1234):