探索黑客技术攻防,实战研究与安全创新

导航菜单

composer在https协议下安装出现 ssl故障

首先,我们先贴一段最新的安装代码。

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"

php -r "if (hash_file('SHA384', 'composer-setup.php') === 'e115a8dc7871f15d853148a7fbac7da27d6c0030b848d9b3dc09e2a0388afed865e6a3d6b3c0fad45c48e2b5fc1196ae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"

php composer-setup.php

php -r "unlink('composer-setup.php');"

因为https是基于ssl的,所以下载的时候需要PHP的SSL控件开启。

1-300x88.png


然后,我们执行第一条命令会发现有错误。

2-300x37.png

这是因为https的ssl证书问题。

我们使用命令php -r "var_dump(openssl_get_cert_locations());"

会发现,CA证书指向了一个奇怪的地方

3-300x267.png

所以我们需要在/ca/cacert.pem下载一份新证书,在PHP.ini中做一下配置就可以正常下载了。

[openssl]

; The location of a Certificate Authority (CA) file on the local filesystem

; to use when verifying the identity of SSL/TLS peers. Most users should

; not specify a value for this directive as PHP will attempt to use the

; OS-managed cert stores in its absence. If specified, this value may still

; be overridden on a per-stream basis via the "cafile" SSL stream context

; option.

openssl.cafile="D:\Program Files\php-5.6.20\cacert.pem"