时间:2021-07-01 10:21:17 帮助过:7人阅读
PHP Notice: 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 in
这里就是把
curl_setopt ( $curl_handle, CURLOPT_SSL_VERIFYHOST, true );
改成
curl_setopt ( $curl_handle, CURLOPT_SSL_VERIFYHOST, 2 );
就可以了吗?
PHP Notice: 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 in
这里就是把
curl_setopt ( $curl_handle, CURLOPT_SSL_VERIFYHOST, true );
改成
curl_setopt ( $curl_handle, CURLOPT_SSL_VERIFYHOST, 2 );
就可以了吗?
是的
CURLOPT_SSL_VERIFYHOST
的值
0
表示不检查证书1
表示检查证书中是否有CN(common name)
字段2
表示在1
的基础上校验当前的域名是否与CN匹配
而libcurl
早期版本中这个变量是boolean
值,为true
时作用同目前设置为2
,后来出于调试需求
,增加了仅校验是否有CN字段
的选项,因此两个值true/false
就不够用了,升级为0/1/2
三个值。
再后来(libcurl_7.28.1
之后的版本),这个调试选项由于经常被开发者用错
,被去掉了,因此目前也不支持1
了,只有0/2
两种取值。
引自 libcurl API
When the verify value is 1, curl_easy_setopt will return an error and
the option value will not be changed. It was previously (in 7.28.0 and
earlier) a debug option of some sorts, but it is no longer supported
due to frequently leading to programmer mistakes. Future versions will
stop returning an error for 1 and just treat 1 and 2 the same.
最新版本,它的默认值就是2
,因此,这行代码,可以省略不写。