composer/ca-bundle
Utility to locate the system CA root bundle for TLS/SSL verification, with a bundled Mozilla CA bundle fallback. Provides helpers to validate CA files and integrate easily with cURL, PHP streams, and Guzzle.
CaBundle class provides hooks (e.g., validateCaFile, reset) for custom validation logic, allowing TPMs to extend functionality without forking the package./etc/ssl/certs/ca-certificates.crt) with CaBundle::getSystemCaRootBundlePath() requires trivial changes in HTTP clients (Guzzle, cURL, streams). Example:
// Before
curl_setopt($curl, CURLOPT_CAINFO, '/etc/ssl/certs/ca-certificates.crt');
// After
curl_setopt($curl, CURLOPT_CAINFO, \Composer\CaBundle\CaBundle::getSystemCaRootBundlePath());
CaBundle::getCaPath()) to abstract implementation details from business logic.openssl extension (enabled by default in Laravel). Validate via extension_loaded('openssl').CaBundle::isOpensslParseSafe() to gracefully handle environments where openssl_x509_parse is disabled.Environment Consistency:
/etc/ssl/certs, /usr/local/etc/openssl/cert.pem) reliable across all deployment environments (dev, staging, prod, containers)?Laravel Ecosystem Integration:
CaBundle::getPath()) or a dedicated service class for easier adoption?config/app.php or .env files?Performance Impact:
CaBundle::reset()) need to be disabled in high-concurrency environments (e.g., serverless)?Compliance and Auditing:
Future-Proofing:
VERIFY option with CaBundle::getSystemCaRootBundlePath().CURLOPT_CAINFO or CURLOPT_CAPATH dynamically.stream_context_create() for file_get_contents().openssl for verification (e.g., Symfony’s HttpClient, AWS SDK, Stripe).Dockerfile:
RUN apt-get update && apt-get install -y ca-certificates # Optional: Ensure base image has CAs
RUN composer require composer/ca-bundle
Phase 1: Pilot in Non-Critical Services
Phase 2: Laravel-Wide Integration
// app/Providers/CaBundleServiceProvider.php
public function register()
{
$this->app->singleton('ca-bundle', function () {
return \Composer\CaBundle\CaBundle::getSystemCaRootBundlePath();
});
}
Phase 3: CI/CD and Containers
C:\Program Files (x86)\Git\mingw64\ssl\certs\ca-bundle.crt if Git is installed.apk add ca-certificates).Dependency Update:
composer.json:
"require": {
"composer/ca-bundle": "^1.5"
}
composer update composer/ca-bundle.Configuration:
Testing:
Monitoring:
openssl extension issues or CA path resolution failures.cacert.pem). No manual intervention required.phpseclib or paragonie/random_compat). Pin to a minor version (e.g., ^1.5) to avoid breaking changes.openssl extension: Add to php.ini or Dockerfile.CaBundle::getSystemCaRootBundlePath() logs.CaBundle::reset() to clear cached paths if environments change dynamically.README section or wiki page for:
CaBundle::reset() on cold starts.How can I help you explore Laravel packages today?