Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

composer-php

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

like image 856
Kundan roy Avatar asked Aug 31 '25 22:08

Kundan roy


2 Answers

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

like image 88
ajtrichards Avatar answered Sep 04 '25 00:09

ajtrichards


You need to reboot your computer.

I had it on virtual environment Vagrant Laravel Homestead.

To fix id I did

vagrant halt
...
vagrant up
like image 24
Yevgeniy Afanasyev Avatar answered Sep 04 '25 01:09

Yevgeniy Afanasyev