curl 支持ws吗,如何检查curl是否支持ssl?

How can I check if php curl was compiled with ssl and has support for ssl?

I mean, a simple check to see if curl is available would be:

if(extension_loaded('curl'))

but how do I check if curl also has support for ssl? I need this check because ssl support is needed to using oauth2 - based API and I need some way to quickly check if client's php is able to the oauth2 before actually using it (and failing)

解决方案

$version = curl_version();

$ssl_supported= ($version['features'] & CURL_VERSION_SSL);

In $version['features'] you have a features bitmask. Through an and operation between this bitmask and the proper constant you can check if a feture is enabled.

Possible constants are:

CURL_VERSION_IPV6 (integer)

CURL_VERSION_KERBEROS4 (integer)

CURL_VERSION_SSL (integer)

CURL_VERSION_LIBZ (integer)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
CURL在cmake中有两种方式来查找和使用,分别是MODULE模式和CONFIG模式。MODULE模式是通过调用cmake内置的FindCURL.cmake脚本来查找CURL,而CONFIG模式是通过引用CURL生成的cmake脚本来查找CURL。 在CURL的cmake脚本中,通过生成一个import target命名为CURL::libcurl来表示CURL的静态库。这个import target有一个属性INTERFACE_LINK_LIBRARIES,它定义了CURL::libcurl所依赖的其他库,包括"wldap32;winmm;ws2_32;OpenSSL::SSL;OpenSSL::Crypto;ZLIB::ZLIB;advapi32;crypt32"等库。 使用CONFIG模式来查找CURL时,先尝试使用CURL的cmake脚本来查找,如果找不到则再使用MODULE模式来查找。这样可以保证在项目中能正确连接到CURL::libcurl target,并且找到它所依赖的其他库。这对于生成动态库或EXE等需要连接的动作非常重要,否则可能会导致连接失败。 因此,在使用CURL的cmake时,建议优先使用CONFIG模式来查找CURL,以确保能够正常连接到CURL::libcurl target。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [cmake:Windows编译支持HTTPS的curl库及find_package查找CURL时需要注意的问题](https://blog.csdn.net/10km/article/details/122812211)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值