• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

curl参数设置的问题 有关CURLOPT_SSL_VERIFYHOST

php 搞代码 4年前 (2022-01-25) 10次浏览 已收录 0个评论
文章目录[隐藏]
<code>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 </code>

这里就是把

<code>curl_setopt ( $curl_handle, CURLOPT_SSL_VERIFYHOST, true );</code>

改成

<code>curl_setopt ( $curl_handle, CURLOPT_SSL_VERIFYHOST, 2 );</code>

就可以了吗?

回复内容:

<code>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 </code>

这里就是把

<code>curl_setopt ( $curl_handle, CURLOPT_SSL_VERIFYHOST, true );</code>

改成

<code>curl_setopt ( $curl_handle, CURLOPT_SSL_VERIFYHOST, 2 );</code>

就可以了吗?

是的

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 va

)本文来源gaodai.ma#com搞#代!码网_

搞代gaodaima码lue 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,因此,这行代码,可以省略不写。


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:curl参数设置的问题 有关CURLOPT_SSL_VERIFYHOST

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址