symfony - 如何在Mink中配置curl参数?

标签 symfony behat mink

我试图将 Behat 引入 https 安全项目,但 mink 在启动curl 请求时失败。

Scenario: Loggin in                              # features/debt.feature:6
    Given I am on "/"                              # FeatureContext::visit()
      [curl] 51: SSL: certificate subject name 'ubuntu' does not match target host name 'wizard' [url] https://wizard/admin/dev.php/ [info] array (
        'url' => 'https://wizard/admin/dev.php/',
        'content_type' => NULL,
        'http_code' => 0,
        'header_size' => 0,
        'request_size' => 0,
        'filetime' => -1,
        'ssl_verify_result' => 1,
        'redirect_count' => 0,
        'total_time' => 0.061943,
        'namelookup_time' => 0.000234,
        'connect_time' => 0.000344,
        'pretransfer_time' => 0,
        'size_upload' => 0,
        'size_download' => 0,
        'speed_download' => 0,
        'speed_upload' => 0,
        'download_content_length' => -1,
        'upload_content_length' => -1,
        'starttransfer_time' => 0,
        'redirect_time' => 0,
        'certinfo' => 
        array (
        ),
      ) [debug] * About to connect() to wizard port 443 (#0)
      *   Trying 127.0.0.1... * connected
      * Connected to wizard (127.0.0.1) port 443 (#0)
      * successfully set certificate verify locations:
      *   CAfile: none
        CApath: /etc/ssl/certs
      * SSL connection using DHE-RSA-AES256-SHA
      * Server certificate:
      *      subject: CN=ubuntu
      *      start date: 2011-05-23 08:26:04 GMT
      *      expire date: 2021-05-20 08:26:04 GMT
      * SSL: certificate subject name 'ubuntu' does not match target host name 'wizard'
      * Closing connection #0

可以通过设置这2个curl参数来解决这个问题:

CURLOPT_SSL_VERIFYPEER = false
CURLOPT_CERTINFO = false

我知道Mink内部使用guzzle,它发起curl请求。如何使用curl选项正确实例化guzzle客户端?

最佳答案

是的,这是已知问题,目前唯一的解决方案是您的 behat.yml 中的类似内容:

default:
    paths:
        features: .
        bootstrap: %behat.paths.features%/bootstrap    
    extensions:
        Behat\MinkExtension\Extension:
            base_url: http://yourhost/
            goutte:
                guzzle_parameters:
                    ssl.certificate_authority: system
                    curl.options:
                        64: false   # CURLOPT_SSL_VERIFYPEER
                        172: false  # CURLOPT_CERTINFO

关于symfony - 如何在Mink中配置curl参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11519290/

相关文章:

php - Symfony - 如何省略 Twig 模板循环中的第一项?

php - 使用 Doctrine 在 Symfony 2 中访问一对多关系时出错

rest - Symfony:如何使用 Voryx REST Bundle 创建一对多关系的 POST 请求

iframe - Mink/behat iframe 没有 id/name

symfony - Behat/Mink 与 Selenium 2 次抛出 "Could not open connection"

php - Symfony2 - 如何在 Controller 中验证电子邮件地址

selenium - 在多个浏览器中并行运行

selenium - [Vagrant][Jenkins][Behat][Selenium]如何组合它们?

php - Behat/Mink 上的 Symfony2 分析器来测试邮件

phantomjs - 我们网站的功能测试