PHP7 SoapClient verify_peer_name : SOAP Error: Could not connect to host

标签 php curl soap paypal php-7

我的 Paypal 代码未使用选项 verify_peer_name => true 运行。当我使用选项 false 尝试相同的 Soap Request 时它起作用了,对我来说似乎是一个 PHP7 错误?这对我适用于 PHP5.3。 我总是得到错误:

无法连接到主机

我已经在我的服务器上安装了证书,我也能够毫无问题地 curl url,只是 SoapClient 没有按预期工作。

有人知道参数verify_peer_name 的真正作用吗?

$client = new SoapClient("https://xxx.paypal/the.wsdl",
    array(
        "trace" => 1,
        "location" => "https://xxx.paypal/the.wsdl",
        'exceptions' => 1,
        "stream_context" => stream_context_create(
            array(
                'ssl' => array(
                    'verify_peer'       => true,
                    'verify_peer_name'  => true,
                )
            )
        )
    ) 
);

最佳答案

我找到了 verify_peer_name 并得到了这个..检查它是否可以帮助你: peer_name 字符串

Peer name to be used. If this value is not set, then the name is guessed based on the hostname used when opening the stream.

verify_peer bool 值

Require verification of SSL certificate used.

Defaults to TRUE.

verify_peer_name bool 值

Require verification of peer name.

Defaults to TRUE.

关于PHP7 SoapClient verify_peer_name : SOAP Error: Could not connect to host,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36628405/

相关文章:

javascript - 将curl选项传递给node js http请求

java - SOAPHandler:如何从子元素中删除自动添加的命名空间/属性

php - Prestashop 使用模块添加产品,无法强制使用 product_id

php - gmail登录后cookie被删除

php - 乘以 1 是清除数值以防止 sql 注入(inject)的安全方法吗?

java - 使用 Java 的 SOAP 请求

java - 如何判断Web服务是REST还是SOAP?

php - 不同模型类型 Laravel 上的不同关系

php - fsockopen 和curl 之间哪个更好?

php - 使用 Curl Php SSL 身份验证的 400 错误请求