The "https://packagist.org/packages.json" file could not be downloaded: SSL operation failed

composer-php

Solution

I came across this issue on OSX after using Homebrew to upgrade to PHP 7.0.12.

To resolve the problem I downloaded `cacert.pem` using WGET.

`wget http://curl.haxx.se/ca/cacert.pem`

I saved that file to my home directory `/Users/alex/cacert.pem`. Then configured my PHP.ini file to point to that cacert location.

To do this; First locate your `php.ini` and run the command `php --ini` that should produce:

$ php --ini
Configuration File (php.ini) Path: /usr/local/etc/php/7.0
Loaded Configuration File:         /usr/local/etc/php/7.0/php.ini
Scan for additional .ini files in: /usr/local/etc/php/7.0/conf.d

The INI file to edit is the one at the Loaded Configuration File location. Open that file in your editor of choice (Vim, etc) and find the setting `openssl.cafile`. This is probably commented out so uncomment it and insert the location of your `cacert.pem`.

You should then be able to run `compose install`, `composer update`, `composer self-update`, etc

Problem

``` When I run the following command ``` sudo composer update ``` then I am getting following error. ``` The "https://packagist.org/packages.json" file could not be downloaded: SSL operation failed with code 1. OpenSSL Error messages: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol Failed to enable crypto failed to open stream: operation failed

Original source