2013-05-21 57 views
1

我正在使用Mink 1.4,使用Goutte驅動程序。貂 - Goutte驅動器cURL SSL錯誤

我試圖在頁面中設置一些表單域值,然後單擊提交該表單的按鈕。

但後來我得到這個錯誤

Fatal error: Uncaught exception 'Guzzle\Http\Exception\CurlException' with message ' in phar://C:/Documents and Settings/User/My Documents/Dropbox/kar_rental/inc/mink.phar/vendor/guzzle/guzzle/src/Guzzle/Http/Curl/CurlMulti.php on line 579 

Guzzle\Http\Exception\CurlException: [curl] 60: SSL certificate problem, verify that the CA cert is OK... 

我認爲因爲我設置CURLOPT_SSL_VERIFYPEER爲false,它不應該檢查SSL。

這裏是我的代碼:

foreach ($this->_sites_data as $site_name => $site_data) 
{ 
    // Instantiate Mink's Goutte Driver 
    $clientOptions = array(
     'curl.options' => array(
      'CURLOPT_SSL_VERIFYPEER' => false, 
      'CURLOPT_CERTINFO' => false, 
      'CURLOPT_TIMEOUT' => 120 
     ), 
     'ssl.certificate_authority' => 'system' 
    ); 

$client = new \Behat\Mink\Driver\Goutte\Client(); 
$client->setClient(new \Guzzle\Http\Client($site_data['form_data']['form_url'], $clientOptions)); 

$driver = new \Behat\Mink\Driver\GoutteDriver($client); 

// Initialize Mink 
$session = new \Behat\Mink\Session($driver); 

// Start session 
$session->start(); 

foreach ($site_data['form_data']['post_fields'] as $days => $post_fields) 
{ 
    // Open form page 
    $session->visit($site_data['form_data']['form_url']); 
    $page = $session->getPage(); 

    foreach ($post_fields as $post_field_name => $post_field_value) 
    { 
     $el = $page->find('css', '#' . $post_field_name); 
     $el->setValue($post_field_value); 
    } 

    $el = $page->find('css', $site_data['form_data']['submit_element_css']); 
    $el->click(); 
} 

$session->reset(); 

}在GOUTTE

回答

0

禁用SSL檢查在你behat.yml文件

goutte: 
    guzzle_parameters: 
      curl.options: 
       CURLOPT_SSL_VERIFYPEER: false 
       CURLOPT_CERTINFO: false 
       CURLOPT_TIMEOUT: 120 
      ssl.certificate_authority: false 

如果失敗嘗試:

<?php 
use Guzzle\Http\Client as GuzzleClient; 
$client = new \Behat\Mink\Driver\Goutte\Client(); 
$gouttedriver = new \Behat\Mink\Driver\GoutteDriver(
    $client 
); 
$client->setClient(new GuzzleClient('', array(
    'curl.CURLOPT_SSL_VERIFYPEER' => false, 
    'curl.CURLOPT_CERTINFO'  => false 
    ))); 
0

我發現了一個適用於Behat/Mink^1.6和Behat/mink-goutte-driver^1.2的配置。

事情是通過驗證假狂飲客戶端作爲一個配置數組:

$配置=陣列( '驗證'=>假);

在這裏,你是我的通用用例:

$client = new \Behat\Mink\Driver\Goutte\Client(); 
    $driver = new \Behat\Mink\Driver\GoutteDriver($client); 

    $client->setClient(new \GuzzleHttp\Client(array(
     'verify' => false, 
    ))); 

    //$driver = new \Behat\Mink\Driver\GoutteDriver($client); 
    $session = new \Behat\Mink\Session($driver); 

    $session->start(); 

    $session->visit(YOUR_URL_COMES_HERE); 
    echo $session->getPage()->getOuterHtml(); 

    $session->stop();