Team Ai
Apppublic

errorcode418/php

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
README.md86 linesDownload Raw Back to ca-bundle
1composer/ca-bundle2==================3 4Small utility library that lets you find a path to the system CA bundle,5and includes a fallback to the Mozilla CA bundle.6 7Originally written as part of [composer/composer](https://github.com/composer/composer),8now extracted and made available as a stand-alone library.9 10 11Installation12------------13 14Install the latest version with:15 16```bash17$ composer require composer/ca-bundle18```19 20 21Requirements22------------23 24* PHP 5.3.2 is required but using the latest version of PHP is highly recommended.25 26 27Basic usage28-----------29 30### `Composer\CaBundle\CaBundle`31 32- `CaBundle::getSystemCaRootBundlePath()`: Returns the system CA bundle path, or a path to the bundled one as fallback33- `CaBundle::getBundledCaBundlePath()`: Returns the path to the bundled CA file34- `CaBundle::validateCaFile($filename)`: Validates a CA file using openssl_x509_parse only if it is safe to use35- `CaBundle::isOpensslParseSafe()`: Test if it is safe to use the PHP function openssl_x509_parse()36- `CaBundle::reset()`: Resets the static caches37 38 39#### To use with curl40 41```php42$curl = curl_init("https://example.org/");43 44$caPathOrFile = \Composer\CaBundle\CaBundle::getSystemCaRootBundlePath();45if (is_dir($caPathOrFile)) {46    curl_setopt($curl, CURLOPT_CAPATH, $caPathOrFile);47} else {48    curl_setopt($curl, CURLOPT_CAINFO, $caPathOrFile);49}50 51$result = curl_exec($curl);52```53 54#### To use with php streams55 56```php57$opts = array(58    'http' => array(59        'method' => "GET"60    )61);62 63$caPathOrFile = \Composer\CaBundle\CaBundle::getSystemCaRootBundlePath();64if (is_dir($caPathOrFile)) {65    $opts['ssl']['capath'] = $caPathOrFile;66} else {67    $opts['ssl']['cafile'] = $caPathOrFile;68}69 70$context = stream_context_create($opts);71$result = file_get_contents('https://example.com', false, $context);72```73 74#### To use with Guzzle75 76```php77$client = new \GuzzleHttp\Client([78    \GuzzleHttp\RequestOptions::VERIFY => \Composer\CaBundle\CaBundle::getSystemCaRootBundlePath()79]);80```81 82License83-------84 85composer/ca-bundle is licensed under the MIT License, see the LICENSE file for details.86