13

I'm trying to install composer on Windows but I get the following error:

The "https://getcomposer.org/versions" file could not be downloaded: SSL operation failed with code 1. OpenSSL Error messages: error: 1416F086: SSL routines: tls_process_server_certificate: certificate verify failed Failed to enable crypto failed to open stream: operation failed.

What's going on and how do I fix this?

HPierce
  • 7,249
  • 7
  • 33
  • 49
Michael García
  • 131
  • 1
  • 1
  • 3
  • 2
    What happens if you try to go to that URL in the web browser on the server? – ceejayoz Jan 27 '18 at 01:42
  • 3
    [This question](https://stackoverflow.com/questions/26148701/file-get-contents-ssl-operation-failed-with-code-1-and-more) seems related. But I *don't* think it's a duplicate. The answers their recommend changing the `file_get_contents()` call, but OP should not be required to modify the composer installation script to get this done. – HPierce Jan 27 '18 at 02:36
  • I have the same error on linode's [lamp stack docker container](https://hub.docker.com/r/linode/lamp/). It's pretty old though, using ubuntu 14.04.1 LTS – ConorSheehan1 Apr 05 '18 at 15:34

9 Answers9

4

I have fixed it, the issue you have encountered seems to be related to a missing certificate.

You just need to add your certificate to end of this file:

C:\xampp\apache\bin\curl-ca-bundle.crt

Here's an example how to append the certificate:

-----BEGIN CERTIFICATE-----

MIIDujCCAqKgAwIBAgILBAAAAAABD4Ym5g0wDQYJKoZIhvcNAQEFBQAwTDEgMB4GA1UECxMXR2xvYmFsU2>lnbiBSb290IENBIC0gUjIxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkdsb2Jh bFNpZ24wHhcNMDYxMjE1MDgwMDAwWhcNMjE... (Your certificate)

-----END CERTIFICATE-----

iLuvLogix
  • 5,920
  • 3
  • 26
  • 43
ndhcoder
  • 71
  • 3
2

I had the same error and this is how I solved the problem: I followed the instructions in https://getcomposer.org/download/, paragraph below Command-line installation

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '55ce33d7678c5a611085589f1f3ddf8b3c52d662cd01d4ba75c0ee0459970c2200a51f492d557530c71c15d8dba01eae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"

I replaced line php composer-setup.php by php composer-setup.php --disable-tls

I got the idea from reviewing the code in composer-setup.php where I found the option. I should have ran php composer-setup.php --help to find the same answer faster and without reading code.

Cody
  • 21
  • 2
1

If you are in private network(Restricted Networking) such as Organization, you have to update their certificate in the "curl-ca-bundle.crt", Copy Paste your organization certificate code in the bottom of the "C:\xampp\apache\bin\curl-ca-bundle.crt" file.

Aravindan
  • 93
  • 9
0

I had the same issue. You have to find below Certificate and install manually to Trusted root of "Current User/Local Computer".

C:\xampp\apache\bin\curl-ca-bundle.crt
0

As a quick workaround I could run composer through its docker image:

docker run --rm --interactive --tty \
  --volume $PWD:/app \
  composer/composer install

I was bitten by this on my local Ubuntu machine. For no apparent reason, composer would time out.

k0pernikus
  • 60,309
  • 67
  • 216
  • 347
0

Experienced same issue and it was caused by VPN app that was running on my computer, exiting it fixed the issue.

  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/33139786) – Josua Marcel C Nov 15 '22 at 18:01
0

I had to exit the VPN for it to work. Posting this for others who may need another alternative if nothing else seems to work.

Jam
  • 1
  • 2
0

I have same error, after a hour work, because my linux server not have ssl, is on public ip. I disable in code the request with https

Use this mode to download

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '55ce33d7678c5a611085589f1f3ddf8b3c52d662cd01d4ba75c0ee0459970c2200a51f492d557530c71c15d8dba01eae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php composer.phar install

I edit file composer-setup.php /usr/src/a2billing/composer-setup.php line 755 remove https

$uriScheme = $this->disableTls ? 'http' : 'http';

and all done, the server can only request on http port 80

marjus-d
  • 1
  • 2
-3

I have fixed it, the issue you have encountered seems to be related to a missing certificate. but if don't have certificate, try this... change composer directory else where but not to desktop and try install again. it's real work to me!!

EricTz
  • 1
  • 1
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/31991314) – Lajos Arpad Jun 14 '22 at 23:29
  • not working in this way. – Brainwash Jun 28 '22 at 14:41