php启用 asynchdns,如何启用php-curl的功能

我需要我的CLI PHP脚本将一些值发布到SPNEGO经过身份验证的站点.

$ch = curl_init(USERSPACE_MYSQL_SERVICES);

curl_setopt_array($ch, [

CURLOPT_HTTPAUTH => ??, //Set to SPNEGO

CURLOPT_POSTFIELDS => [...]

]);

但是SPNEGO因某些原因被禁用:

从我的phpinfo中提取:

curl

cURL support => enabled

cURL Information => 7.21.6

Age => 3

Features

AsynchDNS => No

Debug => No

GSS-Negotiate => Yes

IDN => Yes

IPv6 => Yes

Largefile => Yes

NTLM => Yes

SPNEGO => No

SSL => Yes

SSPI => No

krb4 => No

libz => Yes

CharConv => No

Protocols => dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, pop3, pop3s, rtmp, rtsp, smtp, smtps, telnet, tftp

Host => x86_64-pc-linux-gnu

SSL Version => OpenSSL/1.0.0e

ZLib Version => 1.2.3.4

它正在与之通信的Apache服务器设置如下:

AuthType Kerberos

AuthName "Kerberos LAN Realm Login"

KrbAuthRealm LAN

Krb5KeyTab /etc/apache2/auth/apache2.keytab

KrbMethodK5Passwd Off

KrbSaveCredentials On

KrbLocalUserMapping On

当通过命令行curl尝试它时,它可以工作,但我必须输入一个虚拟密码:

curl --negotiate -u user https://example.com

Enter host password for user 'user':

...

如何为php curl启用SPNEGO以及如何在脚本中使用它?

更新

我尝试过以下方法:

curl_setopt_array($ch, [

CURLOPT_RETURNTRANSFER => true,

CURLOPT_HTTPAUTH => CURLAUTH_ANY,

CURLOPT_POSTFIELDS => [...]

]);

$response = curl_exec($ch);

$info = curl_getinfo($ch);

if ($info['http_code'] >= 400)

die("HTTP ERROR {$info['http_code']}");

echo $response;

我得到:HTTP ERROR 401

解决方法:

看起来您可能需要在configure命令中使用参数“–with-spnego”重新编译curl.

标签:php,curl,kerberos,libcurl,spnego

来源: https://codeday.me/bug/20191007/1865143.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值