php curl密匙已获取到 如何验证,php – cURL无法使用客户端证书(没有找到密钥或错误的密码?)...

我已经在不同的帖子中阅读并尝试了数以千计的解决方案,但似乎没有一个与我合作.这三个就是这样的例子.

密码是正确的,否则它不会转换它.

$xml = 'my xml here';

$url = 'https://qly.mbway.pt/Merchant/requestFinancialOperationWS';

$headers = array(

'Content-Type: text/xml; charset="utf-8"',

'Content-Length: ' . strlen($xml),

'Accept: text/xml',

'Cache-Control: no-cache',

'Pragma: no-cache'

);

$ch = curl_init();

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);

curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);

curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt($ch, CURLOPT_TIMEOUT, 60);

curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

curl_setopt($ch, CURLOPT_SSLCERT, base_url() . 'public/cert.pem');

curl_setopt($ch, CURLOPT_SSLCERTPASSWD, 'my password here');

curl_setopt($ch, CURLOPT_POST, true);

curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);

$data = curl_exec($ch);

if(!$data)

print_r('ERROR: ' . curl_error($ch));

else

print_r('SUCCESS: ' . curl_error($ch));

我尝试过使用SoapUI应用程序并且工作正常但是使用cURL我收到错误:

unable to use client certificate (no key found or wrong pass phrase?)

我试过没有成功:

>禁用CURLOPT_SSL_VERIFYPEER和/或CURLOPT_SSL_VERIFYHOST

>添加CURLOPT_SSLKEYTYPE和/或CURLOPT_SSLKEY字段

编辑1:

除了cURL,我一直在尝试使用SOAPClient,似乎错误可能是标题.

print_r($soapClient)之后的标题如下:

Host: qly.mbway.pt

Connection: Keep-Alive

User-Agent: PHP-SOAP/5.5.9-1ubuntu4.14

Content-Type: application/soap+xml; charset=utf-8; action=""

Content-Length: 1750

我想知道如何删除action =“”?我试图在更改标题方面扩展原始类但没有成功.

class MySoapClient extends SoapClient

{

public function __construct($wsdl, $options = array())

{

$ctx_opts = array('http' => array('header' => array('Content-Type' => 'application/soapyyyyyml')));

$ctx = stream_context_create($ctx_opts);

parent::__construct($wsdl, array('stream_context' => $ctx));

}

}

最佳答案 解决了cURL.

问题是pem文件的路径.

我正在使用base_url(). ‘public / cert.pem’,但这是不可能的.相反,我需要使用相对路径,如./public/cert.pem.

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值