4
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

Kundan roy
  • 3,082
  • 3
  • 18
  • 22

5 Answers5

5

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

ajtrichards
  • 29,723
  • 13
  • 94
  • 101
1

You need to reboot your computer.

I had it on virtual environment Vagrant Laravel Homestead.

To fix id I did

vagrant halt
...
vagrant up
Yevgeniy Afanasyev
  • 37,872
  • 26
  • 173
  • 191
0

Certain Composer commands, including exec, install, and update allow third party code to execute on your system. This is from its "plugins" and "scripts" features. Plugins and scripts have full access to the user account which runs Composer. For this reason, it is strongly advised to avoid running Composer as super-user/root.

You can disable plugins and scripts during package installation or updates with the following syntax so only Composer's code, and no third party code, will execute:

composer install --no-plugins --no-scripts
composer update --no-plugins --no-scripts

The exec command will always run third party code as the user which runs composer.

In some cases, like in CI systems or such where you want to install untrusted dependencies, the safest way to do it is to run the above command.

so always run composer without sudo
Kundan roy
  • 3,082
  • 3
  • 18
  • 22
0

I've tried these solutions, but none of them worked for me. I know it may sounds like a dummy workaround, but this what I did in case anyone find it useful:

1) temporarily I enabled my mobile as a wifi hotspot. 2) connected my laptop to this wifi. I have my Vagrant VM here, with Laravel/Composer running. 3) I disabled all proxy environment settings (e.g. http_proxy, https_proxy, etc) within my VM. 4) Then, I successfully created my project, by using "composer global require "laravel/installer" and "composer create-project laravel/laravel" commands. 5) disconnected the wifi hotspot, and started to work normally (ethernet).

HTH. Carlos.

CContreras
  • 81
  • 4
0

I met this issue on Virtualbox - Ubuntu / Docker / PHP7 and fix by restarting the Ubuntu.