Skip to content

Requests default certificate fails to load from Phar #5779

@schlessera

Description

@schlessera

Bug Report

Describe the current, buggy behavior

The current integration with the Requests library surfaces an issue when the default certificate location provided by the Requests library has not been overridden and the library is found within the WP-CLI Phar file.

In that scenario, the location to the certificate file still points into the Phar file, and cURL cannot properly handle that file location, as it is unable to read archived files within Phar archives.

Describe how other contributors can replicate this bug

The behavior can be replicated by building a Phar archive an running tests using that Phar archive via WP_CLI_BIN_DIR:

  1. Clone the wp-cli/wp-cli-bundle repository and cd into its folder.
  2. Run composer install
  3. Run php -dphar.readonly=0 utils/make-phar.php wp-cli.phar --version=custom
  4. Run mv wp-cli.phar wp && chmod +x wp
  5. Run WP_CLI_BIN_DIR=/home/alain/wp-cli-bundle composer behat

Describe what you expect as the correct outcome

The tests should succeed.

But instead, they produce an error:

PHP Fatal error:  Uncaught WpOrg\Requests\Exception: cURL error 77: error setting certificate verify locations:
          CAfile: phar://wp/vendor/rmccue/requests/src/../certificates/cacert.pem
          CApath: /etc/ssl/certs in phar://wp/vendor/rmccue/requests/src/Transport/Curl.php:490

Provide additional context/screenshots

Merge pull request #534 from wp-cli_update-composer-lock-file-2023-05-03 ·   2023-05-04 at 11 30 58 AM

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions