SSL Error at Composer Install

2019-02-26 11:28发布

While installing Composer to XAMPP, I got some errors. My system OS was Windows 7, how can I solve this and install Composer?

Download failed: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed file_get_contents(): Failed to enable crypto file_get_contents(https://getcomposer.org/composer.phar.sig): failed to open stream: operation failed Download failed: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed file_get_contents(): Failed to enable crypto file_get_contents(https://getcomposer.org/composer.phar.sig): failed to open stream: operation failed

2条回答
ら.Afraid
2楼-- · 2019-02-26 11:59

Make sure you configured the path to the ca certificates in php.ini:

curl.cainfo=/full/path/to/ssl/certs/ca-bundle.crt
openssl.cafile=/full/path/to/ssl/certs/ca-bundle.crt

In case you don't have a ca certificate bundle download it:

https://raw.githubusercontent.com/bagder/ca-bundle/master/ca-bundle.crt

To install Composer (without using cURL):

php -r "readfile('https://getcomposer.org/installer');" | php

Or, to install Composer (with cURL):

curl -sS https://getcomposer.org/installer | php

(If that doesn't work out, simple download the Composer PHAR via your browser.

https://getcomposer.org/composer.phar

But, you will run into the issue again, when fetching packages, until you fix the certificate issue.)

查看更多
来,给爷笑一个
3楼-- · 2019-02-26 12:04

That's exactly the same issue I'm facing. While installing the Composer Installer on my Windows 7 machine I'm getting the below error:

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

Tried this:

$ curl -sS https://getcomposer.org/installer | php
stdin is not a tty
curl: (60) SSL certificate problem: self signed certificate in certificate chain
More details here: https://curl.haxx.se/docs/sslcerts.html

curl performs SSL certificate verification by default, using a "bundle"
 of Certificate Authority (CA) public keys (CA certs). If the default
 bundle file isn't adequate, you can specify an alternate file
 using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
 the bundle, the certificate verification probably failed due to a
 problem with the certificate (it might be expired, or the name might
 not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
 the -k (or --insecure) option.

And this:

$ ping getcomposer.org

Pinging getcomposer.org [87.98.253.108] with 32 bytes of data:
Reply from 87.98.253.108: bytes=32 time=137ms TTL=47
Reply from 87.98.253.108: bytes=32 time=127ms TTL=47
Reply from 87.98.253.108: bytes=32 time=127ms TTL=47
Reply from 87.98.253.108: bytes=32 time=127ms TTL=47

Ping statistics for 87.98.253.108:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 127ms, Maximum = 137ms, Average = 129ms

My PHP version is:

$ php -v
PHP 5.5.37 (cli) (built: Jun 22 2016 16:14:46)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies

I've enabled the following list in my php.ini:

extension=php_curl.dll
extension=php_openssl.dll
curl.cainfo="C:/xampp/php/extras/certs/cacert.pem"
openssl.cafile="C:/xampp/php/extras/certs/cacert.pem"

Where I've downloaded the cacert.pem from https://curl.haxx.se/ca/cacert.pem

I was missing to add the proxy settings while installation, when added it worked like charm! :)

http://username:password@your_proxy:your_port
查看更多
登录 后发表回答