How to adjust curl parameters in a mink?

I am trying to bring Behat to a https protected project and a mink crash when initiating a curl request.

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 

The problem can be solved by setting these two curl parameters:

 CURLOPT_SSL_VERIFYPEER = false CURLOPT_CERTINFO = false 

I know that Mink internally uses gzzle, which initiates curl requests. How to create a click instance with curl parameters?

+4
source share
4 answers

Yes, this known issue and the only solution at the moment is something like this in your 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 
+5
source

Now you need to set the following in behat.yml:

 default: extensions: Behat\MinkExtension\Extension: goutte: guzzle_parameters: curl.options: CURLOPT_SSL_VERIFYPEER: 0 CURLOPT_CERTINFO: 0 CURLOPT_SSL_VERIFYHOST: 0 ssl.certificate_authority: system 

After this stretch request https://github.com/guzzle/guzzle/pull/498 you can simply do:

 default: extensions: Behat\MinkExtension\Extension: goutte: guzzle_parameters: ssl.certificate_authority: false 

Please note that I use string constants instead of integers, as they are more readable. You do not need to use integers here, since the correct constant / integer conversion is done inside Guzzle.

In addition, I added CURLOPT_SSL_VERIFYHOST, which will solve your problem.

+2
source

Mink uses Goutte, which internally initializes Guzzle (see https://github.com/fabpot/Goutte/blob/master/Goutte/Client.php#L45 ).

Here you can initialize Guzzle to solve your problem: https://github.com/fabpot/Goutte/issues/63#issuecomment-6371727

Although there are several ways to solve this problem, the simplest solutions that I see now are

Another (possibly cleaner) way would be to change the service definition with a compiler pass and force it to call setClient ().

0
source

my decision:

 /** * * @BeforeScenario * @return void */ public function doNotCheckSsl() { $strUrl = $this->getMinkParameter( 'base_url' ); $objGuzzleClient = new GuzzleClient( $strUrl ); $objGuzzleClient->setSslVerification( false, false, 0 ); $objClient = new GoutteClient(); $objDriver = new GoutteDriver( $objClient ); $objClient->setClient( $objGuzzleClient ); $objSession = new Session( $objDriver ); $objSession->start(); $this->getMink()->registerSession( 'sess', $objSession ); $this->getMink()->setDefaultSessionName( 'sess' ); } 
0
source

All Articles