douxuqiao6394 2014-05-19 07:54
浏览 20

ByPass使用Artax进行SSL证书验证

When making a POST request to a server with an invalid SSL certificate ( Cloudflare has to reissue the certificate ), Artax returns the following error:

stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

I have attempted to use

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

and

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

However in both cases errors are thrown.

Can anyone shed light on the correct method to disable peer verification with Artax?


Update

I've tried both:

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

And

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

Both give me a response of 400 ( Bad Request ).

[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
            )
  • 写回答

2条回答 默认 最新

  • dongzhan1383 2014-05-19 08:07
    关注

    Maybe allowing self signed would work :

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

报告相同问题?

悬赏问题

  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值