Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Composer behind proxy (https) #2041

Closed
robertdolca opened this issue Jun 26, 2013 · 14 comments
Closed

Composer behind proxy (https) #2041

robertdolca opened this issue Jun 26, 2013 · 14 comments

Comments

@robertdolca
Copy link

I am trying to use composer behind a proxy and I am unable to access https urls.

composer.phar diag output

Checking platform settings: OK
Checking http connectivity: OK
Checking HTTP proxy: OK
Checking HTTP proxy support for request_fulluri: OK
Checking HTTPS proxy support for request_fulluri: FAIL
Unable to assert the situation, maybe github is down (The "https://api.github.com/repos/Seldaek/jsonlint/zipball/1.0.0" file could not be downloaded: failed to open stream: Cannot connect to HTTPS server through proxy)
Checking composer.json: OK
Checking disk free space: OK
Checking composer version: OK

I tried with HTTP_PROXY_REQUEST_FULLURI or HTTPS_PROXY_REQUEST_FULLURI false value.
I have hpp_proxy and https_proxy set and correct. I also checked OpenSSL version and it is 1.0.1. Is this a known issue?

@Seldaek
Copy link
Member

Seldaek commented Jun 26, 2013

Do you have two different proxies for http and https? Right now composer only reads the http_proxy env var, so that might be an issue we need to address.

@robertdolca
Copy link
Author

No. They are identical.

@fweber-de
Copy link

it doesnt work with just the http_proxy variable either

@Seldaek
Copy link
Member

Seldaek commented Jun 26, 2013

Then I am not sure what's up.. I guess it works in your browser since you're posting here so your proxy is probably not to blame. Which version of openssl 1.0.1 do you have? Very old variants might be buggy, but I think the whole 1.0.1 range should work.

@fweber-de
Copy link

for me, it is 1.0.1c

@robertdolca
Copy link
Author

1.0.1-4ubuntu5.9
The proxy works fine with apt or in browser (https)

@Razorfazor
Copy link

There are multiple problems, if using composer behind a proxy. I wouldn't say the problem starts with a buggy openssl versions:

error message of "composer diag":

Checking platform settings: OK
Checking http connectivity: FAIL
[Composer\Downloader\TransportException] The "https://packagist.org/packages.json" file could not be downloaded: SSL: Connection reset by peer
failed to open stream: Cannot connect to HTTPS server through proxy
Checking HTTP proxy: FAIL
[Composer\Downloader\TransportException] The "https://packagist.org/packages.json" file could not be downloaded: SSL: Connection reset by peer
failed to open stream: Cannot connect to HTTPS server through proxy
Checking HTTP proxy support for request_fulluri: OK
Checking HTTPS proxy support for request_fulluri: FAIL
Unable to assert the situation, maybe github is down (The "https://api.github.com/repos/Seldaek/jsonlint/zipball/1.0.0" file could not be downloaded: SSL: Connection reset by peer
failed to open stream: Cannot connect to HTTPS server through proxy)
Checking composer.json: OK
Checking disk free space: OK
Checking composer version:

[Composer\Downloader\TransportException]
The "https://getcomposer.org/version" file could not be downloaded: SSL: Connection reset by peer
failed to open stream: Cannot connect to HTTPS server through proxy

As you see, if composer tries to check for the http connectivity it checks directly for the https://packagist.org . That might be a problem of the permanent redirect of packagist.org (from http to https) or because it might switch automatically to https if openssl is enabled. So better check a different url and the diag procedure might not be correct.

I can succesfully load https://packagist.org via wget (with --no-check-certificate) and via curl (with -sS).

my exported environment variables:

export http_proxy=myproxy
export https_proxy=myproxy
export HTTP_PROXY=myproxy
export HTTPS_PROXY=myproxy
export HTTP_PROXY_REQUEST_FULLURI=false
export HTTPS_PROXY_REQUEST_FULLURI=false

openssl version: 0.9.8
Updating the openssl is not an option, because of company policy.

disabling openssl and running "composer install --prefer-dist -vvv" let's me download the packages but when times come to install them:

  • Installing psr/log (1.0.0)

    [RuntimeException]
    You must enable the openssl extension to download files via https

Any ideas, what I should try?

@Seldaek
Copy link
Member

Seldaek commented Jul 8, 2013

You can use --prefer-source as a workaround but that can make installs
pretty slow.

@Razorfazor
Copy link

Problem solved.
Our proxy blocks every request to https sites without any User-agent.

@DanielKaupp
Copy link

Hi,
i'm experiencing similar issues:

Checking http connectivity: FAIL
[Composer\Downloader\TransportException] The "https://packagist.org/packages.json" file could not be downloaded: SSL: Connection reset by peer

I'm using an actual Version of Lubuntu in a VMWare VM. I don't know, if I have a proxy, that is preventing something, but the Windows Host System has no problems connecting to composer via https.

I'm posting from my VM, so https in general is also not the problem.

What could it be, and how can i fix it?

Thanks, Daniel

@ViniciusAugusto
Copy link

Hi,
I have the same problem, someone has a solution?

$ php composer.phar install
Loading composer repositories with package information
The "https://packagist.org/packages.json" file could not be downloaded: SSL: crypto enabling timeout
Failed to enable crypto
failed to open stream: operation failed
https://packagist.org could not be fully loaded, package information was loaded from the local cache and may be out of date
Installing dependencies (including require-dev)

[Composer\Repository\RepositorySecurityException]
The contents of http://packagist.org/p/zendframework/zendframework$6a3fb12d
681977009a9df5cb45d1203dc65b8722c9211407e0db8fc18f3d27c6.json do not match
its signature. This should indicate a man-in-the-middle attack. Try running
composer again and report this if you think it is a mistake.

install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-plugins] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [--ignore-platform-reqs] [packages1] ... [packagesN]

@ghost
Copy link

ghost commented Nov 14, 2015

locate cacert.pem

vi /usr/local/lib/php.ini

#add this

openssl.cafile=/usr/local/share/perl5/Mozilla/CA/cacert.pem

press esc then type

:wq #enter

curl -sS https://getcomposer.org/installer | php -- —version=1.0.0-alpha10

mv composer.phar /usr/local/bin/composer

alias composer='/usr/local/bin/composer'

composer -V

php /usr/local/bin/composer global self-update

cd .composer/
composer init

@mrbrazzi
Copy link

Hi,
I have the same problem, but I'm working on Windows 10.

I setup system variables like:
HTTP_PROXY = http://%PROXY_USER%:%PROXY_PASSWORD%@%PROXY_SERVER%:%PROXY_PORT%
HTTP_PROXY_REQUEST_FULLURI = 0
HTTPS_PROXY = https://%PROXY_USER%:%PROXY_PASSWORD%@%PROXY_SERVER%:%PROXY_PORT%
HTTPS_PROXY_REQUEST_FULLURI = 0

And when I executed:

D:\Apps\Composer>composer diag -vvv
Reading ./composer.json
Loading config file D:\Apps\Composer/config.json
Loading config file D:\Apps\Composer/auth.json
Loading config file ./composer.json
Loading config file D:\Apps\Composer/auth.json
Reading D:\Apps\Composer/auth.json
Checked CA file C:\Users\brazzi\AppData\Local\Temp\composer-cacert-bcf331364fef73d53e4368ba519a6c3fcb21ea7836c3d8efad4ec32731e8152a.pem: valid
Executing command (D:\Apps\Composer): git branch --no-color --no-abbrev -v
Executing command (D:\Apps\Composer): git describe --exact-match --tags
Executing command (D:\Apps\Composer): git log --pretty="%H" -n1 HEAD
Running 1.2.0 (2016-07-19 01:28:52) with PHP 5.5.30 on Windows NT / 10.0
You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug
Checking composer.json: Reading ./composer.json
**FAIL**
No license specified, it is recommended to do so. For closed-source software you may use "proprietary" as license.
Checking platform settings: **FAIL**
The xdebug extension is loaded, this can slow down Composer a little.
 Disabling it when using Composer is recommended.

Checking git settings: Executing command (CWD): git config color.ui
**OK**
Checking http connectivity to packagist: Downloading http://packagist.org/packages.json using proxy tcp://proxy.domain.cu:3128
Warning: Accessing packagist.org over http which is an insecure protocol.
**FAIL**
[Composer\Downloader\TransportException] The 'http://packagist.org/packages.json' URL could not be accessed: HTTP/1.0 400 Bad Request

Checking https connectivity to packagist: Downloading https://packagist.org/packages.json using proxy ssl://proxy.domain.cu:3128
**FAIL**
[Composer\Downloader\TransportException] 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
Checking HTTP proxy: Downloading https://packagist.org/packages.json using proxy ssl://proxy.domain.cu:3128
**FAIL**
[Composer\Downloader\TransportException] 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
Checking HTTP proxy support for request_fulluri: Downloading http://packagist.org/packages.json using proxy tcp://proxy.domain.cu:3128
Downloading http://packagist.org/packages.json using proxy tcp://proxy.domain.cu:3128
**FAIL**
Unable to assess the situation, maybe packagist.org is down (The 'http://packagist.org/packages.json' URL could not be accessed: HTTP/1.0 400 Bad Request
)
Checking HTTPS proxy support for request_fulluri: Downloading https://api.github.com/repos/Seldaek/jsonlint/zipball/1.0.0 using proxy ssl://proxy.domain.cu:3128
Downloading https://api.github.com/repos/Seldaek/jsonlint/zipball/1.0.0 using proxy ssl://proxy.domain.cu:3128
**FAIL**
Unable to assess the situation, maybe github is down (The "https://api.github.com/repos/Seldaek/jsonlint/zipball/1.0.0" 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)
Checking github.com oauth access: Downloading https://api.github.com/ using proxy ssl://proxy.domain.cu:3128
**FAIL**
[Composer\Downloader\TransportException] The "https://api.github.com/" 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
Checking disk free space: OK
Checking pubkeys:
Tags Public Key Fingerprint: 57815BA2 7E54DC31 7ECC7CC5 573090D0  87719BA6 8F3BB723 4E5D42D0 84A14642
Dev Public Key Fingerprint: 4AC45767 E5EC2265 2F0C1167 CBBB8A2B  0C708369 153E328C AD90147D AFE50952
OK
Checking composer version: Downloading https://getcomposer.org/versions using proxy ssl://proxy.domain.cu:3128


  [Composer\Downloader\TransportException]
  The "https://getcomposer.org/versions" file could not be downloaded: SSL operation failed with code 1. OpenSSL Erro
  r messages:
  error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol
  Failed to enable crypto
  failed to open stream: operation failed


Exception trace:
 () at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Util/RemoteFilesystem.php:482
 Composer\Util\RemoteFilesystem->get() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Util/RemoteFilesystem.php:101
 Composer\Util\RemoteFilesystem->getContents() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/SelfUpdate/Versions.php:65
 Composer\SelfUpdate\Versions->getLatest() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Command/DiagnoseCommand.php:371
 Composer\Command\DiagnoseCommand->checkVersion() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Command/DiagnoseCommand.php:145
 Composer\Command\DiagnoseCommand->execute() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/vendor/symfony/console/Command/Command.php:259
 Symfony\Component\Console\Command\Command->run() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/vendor/symfony/console/Application.php:844
 Symfony\Component\Console\Application->doRunCommand() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/vendor/symfony/console/Application.php:192
 Symfony\Component\Console\Application->doRun() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Console/Application.php:231
 Composer\Console\Application->doRun() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/vendor/symfony/console/Application.php:123
 Symfony\Component\Console\Application->run() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Console/Application.php:104
 Composer\Console\Application->run() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/bin/composer:43
 require() at C:\ProgramData\ComposerSetup\bin\composer.phar:24

diagnose


D:\Apps\Composer>

What I'm missing?

Thanks in advance

@thenameishidden
Copy link

Same problem. Windows 10, PHP 7.1 - 7.3,

I had have old version of composer and there is the same problem.
First, I set

HTTP_PROXY = http://%PROXY_USER%:%PROXY_PASSWORD%@%PROXY_SERVER%:%PROXY_PORT%
HTTP_PROXY_REQUEST_FULLURI = 0
HTTPS_PROXY = https://%PROXY_USER%:%PROXY_PASSWORD%@%PROXY_SERVER%:%PROXY_PORT%
HTTPS_PROXY_REQUEST_FULLURI = 0

Still problem.

I download manual latest version of composer: 1.8.6 | 2019-06-11

Still problem.

Try PHP 7.1, PHP 7.3

Still problem.

I even add my PHP and Apache to windows firewall, but.
Still problem.

composer diagnose
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: [Composer\Downloader\TransportException] The "http://repo.packagist.org/packages.json" file could not be downloaded (HTTP/1.1 502 Proxy Error ( The Uniform Resource Locator (URL) does not use a recognized protocol. Either the protocol is not s)
Checking https connectivity to packagist: OK
Checking HTTP proxy: FAIL
[ErrorException] reset() expects parameter 1 to be array, null given
Checking HTTP proxy support for request_fulluri: Unable to assess the situation, maybe packagist.org is down (The "http://repo.packagist.org/packages.json" file could not be downloaded (HTTP/1.1 502 Proxy Error ( The Uniform Resource Locator (URL) does not use a recognized protocol. Either the protocol is not s))
Checking HTTPS proxy support for request_fulluri: OK
Checking github.com rate limit: FAIL
Checking disk free space: OK
Checking pubkeys: FAIL
Missing pubkey for tags verification
Missing pubkey for dev verification
Run composer self-update --update-keys to set them up
Checking composer version:

  [Seld\JsonLint\ParsingException]
  "" does not contain valid JSON
  Parse error on line 1:

  ^
  Expected one of: 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '['


diagnose

AND

# composer diag -vvv
Loading config file C:/Users/AdminGD/AppData/Roaming/Composer/config.json
Loading config file C:/Users/AdminGD/AppData/Roaming/Composer/auth.json
Failed to initialize global composer: Composer could not find the config file: C:/Users/AdminGD/AppData/Roaming/Composer/composer.json
To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section
Running 1.8.6 (2019-06-11 15:03:05) with PHP 7.3.2 on Windows NT / 10.0
Loading config file C:/Users/AdminGD/AppData/Roaming/Composer/config.json
Loading config file C:/Users/AdminGD/AppData/Roaming/Composer/auth.json
Failed to initialize global composer: Composer could not find the config file: C:/Users/AdminGD/AppData/Roaming/Composer/composer.json
To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section
Checked CA file D:\Portable\OSPanel\modules\php\PHP_7.3-x64\cacert.pem: valid
Checking platform settings: OK
Checking git settings: Executing command (CWD): git config color.ui
OK
Checking http connectivity to packagist: Downloading http://repo.packagist.org/packages.json using proxy tcp://dmk-hptmg.dmkd.dp.ua:8080
[Composer\Downloader\TransportException] The "http://repo.packagist.org/packages.json" file could not be downloaded (HTTP/1.1 502 Proxy Error ( The Uniform Resource Locator (URL) does not use a recognized protocol. Either the protocol is not s)
Checking https connectivity to packagist: Downloading https://repo.packagist.org/packages.json using proxy tcp://dmk-hptmg.dmkd.dp.ua:8080
OK
Checking HTTP proxy: Downloading https://repo.packagist.org/packages.json using proxy tcp://dmk-hptmg.dmkd.dp.ua:8080
FAIL
[ErrorException] reset() expects parameter 1 to be array, null given
Checking HTTP proxy support for request_fulluri: Downloading http://repo.packagist.org/packages.json using proxy tcp://dmk-hptmg.dmkd.dp.ua:8080
Downloading http://repo.packagist.org/packages.json using proxy tcp://dmk-hptmg.dmkd.dp.ua:8080
Unable to assess the situation, maybe packagist.org is down (The "http://repo.packagist.org/packages.json" file could not be downloaded (HTTP/1.1 502 Proxy Error ( The Uniform Resource Locator (URL) does not use a recognized protocol. Either the protocol is not s))
Checking HTTPS proxy support for request_fulluri: Downloading https://api.github.com/repos/Seldaek/jsonlint/zipball/1.0.0 using proxy tcp://dmk-hptmg.dmkd.dp.ua:8080
OK
Checking github.com rate limit: Downloading https://api.github.com/rate_limit using proxy tcp://dmk-hptmg.dmkd.dp.ua:8080
FAIL
Checking disk free space: OK
Checking pubkeys: FAIL
Missing pubkey for tags verification
Missing pubkey for dev verification
Run composer self-update --update-keys to set them up
Checking composer version: Downloading https://getcomposer.org/versions using proxy tcp://dmk-hptmg.dmkd.dp.ua:8080


  [Seld\JsonLint\ParsingException]
  "" does not contain valid JSON
  Parse error on line 1:

  ^
  Expected one of: 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '['


Exception trace:
 () at phar://D:/Portable/OSPanel/modules/php/PHP_7.3-x64/composer.phar/src/Composer/Json/JsonFile.php:299
 Composer\Json\JsonFile::validateSyntax() at phar://D:/Portable/OSPanel/modules/php/PHP_7.3-x64/composer.phar/src/Composer/Json/JsonFile.php:272
 Composer\Json\JsonFile::parseJson() at phar://D:/Portable/OSPanel/modules/php/PHP_7.3-x64/composer.phar/src/Composer/SelfUpdate/Versions.php:65
 Composer\SelfUpdate\Versions->getLatest() at phar://D:/Portable/OSPanel/modules/php/PHP_7.3-x64/composer.phar/src/Composer/Command/DiagnoseCommand.php:433
 Composer\Command\DiagnoseCommand->checkVersion() at phar://D:/Portable/OSPanel/modules/php/PHP_7.3-x64/composer.phar/src/Composer/Command/DiagnoseCommand.php:156
 Composer\Command\DiagnoseCommand->execute() at phar://D:/Portable/OSPanel/modules/php/PHP_7.3-x64/composer.phar/vendor/symfony/console/Command/Command.php:245
 Symfony\Component\Console\Command\Command->run() at phar://D:/Portable/OSPanel/modules/php/PHP_7.3-x64/composer.phar/vendor/symfony/console/Application.php:835 Symfony\Component\Console\Application->doRunCommand() at phar://D:/Portable/OSPanel/modules/php/PHP_7.3-x64/composer.phar/vendor/symfony/console/Application.php:185
 Symfony\Component\Console\Application->doRun() at phar://D:/Portable/OSPanel/modules/php/PHP_7.3-x64/composer.phar/src/Composer/Console/Application.php:258
 Composer\Console\Application->doRun() at phar://D:/Portable/OSPanel/modules/php/PHP_7.3-x64/composer.phar/vendor/symfony/console/Application.php:117
 Symfony\Component\Console\Application->run() at phar://D:/Portable/OSPanel/modules/php/PHP_7.3-x64/composer.phar/src/Composer/Console/Application.php:104
 Composer\Console\Application->run() at phar://D:/Portable/OSPanel/modules/php/PHP_7.3-x64/composer.phar/bin/composer:61
 require() at D:\Portable\OSPanel\modules\php\PHP_7.3-x64\composer.phar:24

diagnose

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants