composer/ca-bundle
Find the system CA root bundle path for TLS verification, with automatic fallback to a bundled Mozilla CA file. Simple API for curl, PHP streams, and HTTP clients like Guzzle; includes CA file validation and cache reset utilities.
CURLOPT_CAINFO).VERIFY option with CaBundle::getSystemCaRootBundlePath().curl_setopt() in custom HTTP clients or middleware.file_get_contents() or stream_context_create().Illuminate\Http\Middleware).| Risk Area | Mitigation Strategy |
|---|---|
| PHP version mismatch | Laravel 10+ uses PHP 8.1+; package supports PHP 5.3.2 but recommends latest. Use 1.5.x branch for PHP 8.4+ compatibility. |
| OpenSSL parsing safety | Package includes isOpensslParseSafe(); validate before use in production. |
| Path resolution failures | Fallback to bundled Mozilla CA ensures no breaking changes if system paths are misconfigured. |
| Performance overhead | Minimal (static caching); benchmark in high-throughput environments (e.g., API gateways). |
| Dependency bloat | Package is ~1MB (CA bundle + code); negligible for most Laravel apps. |
1.4.x branch to avoid deprecation warnings.CaBundle::getSystemCaRootBundlePath().CaBundle::reset() to clear cached paths between runs.^1.5) to avoid unexpected updates.VERIFY option with CaBundle::getSystemCaRootBundlePath() in the HttpClient facade or custom clients.App\Http\Middleware\SslValidation) or Artisan commands.Storage facade or file_get_contents() via stream_context_create().Client class to auto-inject CA paths.CaBundle to test SSL failure scenarios (e.g., revoked certs).cURL 60/77).// app/Providers/CaBundleServiceProvider.php
public function register()
{
$caPath = \Composer\CaBundle\CaBundle::getSystemCaRootBundlePath();
Http::withOptions(['verify' => $caPath]);
}
// app/Http/Middleware/EnforceSslValidation.php
public function handle($request, Closure $next)
{
$caPath = \Composer\CaBundle\CaBundle::getSystemCaRootBundlePath();
if (str_starts_with($request->fullUrl(), 'https')) {
$request->merge(['ca_path' => $caPath]);
}
return $next($request);
}
| Component | Compatibility Notes |
|---|---|
| Laravel 10/11 | Full support (PHP 8.1+). Use 1.5.x branch. |
| Laravel 9 | Works with PHP 8.0; use 1.4.x branch. |
| Legacy Laravel | PHP 5.3.2+ supported, but not recommended (security risks). |
| Docker/Kubernetes | Critical for self-signed certs or missing system CAs (e.g., Alpine Linux). |
| Windows IIS | May require path adjustments (test CaBundle::getSystemCaRootBundlePath()). |
| CI/CD (GitHub Actions) | Resolves cURL SSL certificate problem errors in workflows. |
composer.json and run composer require composer/ca-bundle.monolog or Sentry).^1.5) to avoid surprises.// config/ca-bundle.php
return [
'custom_paths' => [
'/etc/ssl/certs/custom-ca.pem',
],
];
CaBundle::reset() to clear static caches in long-running processes (e.g., Laravel queues).openssl_x509_parse() failures → Check CaBundle::isOpensslParseSafe()./etc/ssl/certs on Linux).CaBundle::getSystemCaRootBundlePath() and CaBundle::getBundledCaBundlePath().CaBundle::validateCaFile() to test CA file integrity.1.5.8).| Failure Scenario | Impact | Mitigation Strategy |
|---|---|---|
| System CA path missing | Fallback to bundled CA. |
How can I help you explore Laravel packages today?