ByPass使用Artax进行SSL证书验证

时间:2014-05-19 07:54:36

标签: php ssl artax

向具有无效SSL证书的服务器发出POST请求时(Cloudflare必须重新颁发证书),Artax会返回以下错误:

  

stream_socket_enable_crypto():SSL操作失败,代码为1. OpenSSL错误消息:   错误:14090086:SSL例程:SSL3_GET_SERVER_CERTIFICATE:证书验证失败

我试图使用

$client->setOption('tlsOptions', [
    'verify_peer' => FALSE,
]);

$request->setOption('tlsOptions', [
    'verify_peer' => FALSE,
]);

然而,在这两种情况下都会抛出错误。

有人能说明使用Artax禁用同行验证的正确方法吗?


更新

我试过了两个:

$client->setAllOptions([
    'tlsOptions' => [
        'verify_peer' => FALSE,
        'allow_self_signed' => TRUE,
    ],
]);

$client->setOption('tlsOptions', [
    'verify_peer' => FALSE,
    'allow_self_signed' => TRUE,
]);

两者都给我400响应(错误请求)。

[status:Artax\Response:private] => 400
        [reason:Artax\Response:private] => Bad Request
        [protocol:Artax\Message:private] => 1.1
        [headers:Artax\Message:private] => Array
            (
                [Date] => Array
                    (
                        [0] => Mon, 19 May 2014 09:50:19 GMT
                    )

                [Server] => Array
                    (
                        [0] => Apache/2.4.9 (Ubuntu)
                    )

                [Content-Length] => Array
                    (
                        [0] => 303
                    )

                [Connection] => Array
                    (
                        [0] => close
                    )

                [Content-Type] => Array
                    (
                        [0] => text/html; charset=iso-8859-1
                    )

            )

        [headerCaseMap:Artax\Message:private] => Array
            (
                [DATE] => Date
                [SERVER] => Server
                [CONTENT-LENGTH] => Content-Length
                [CONNECTION] => Connection
                [CONTENT-TYPE] => Content-Type
            )

1 个答案:

答案 0 :(得分:0)

也许允许自签名会起作用:

$client->setOption('tlsOptions', [
    'verify_peer' => FALSE,
    'allow_self_signed' => TRUE,
    ]);