spatie/ssl-certificate-chain-resolver
Resolves incomplete SSL certificate chains by discovering and returning the missing intermediate certificates between a site’s cert and trusted roots. Helps fix “Extra download” issues flagged by SSL Labs, improving compatibility for mobile and strict clients.
openssl extension to fetch and inject missing intermediate certificates dynamically. No changes to web server (Nginx/Apache) or OS-level CA stores required.Http, Guzzle) and queue workers (e.g., for async tasks like webhook processing). Can be wrapped in a service provider or facade for consistency.openssl extension (enabled by default in Laravel).openssl: Requires PHP’s openssl extension (standard in Laravel). Mitigation: Validate extension presence in composer.json or CI/CD.openssl responses)?Http client or Guzzle via middleware or client events.Illuminate\Queue\Events\JobProcessed).ssl:resolve command to pre-fetch chains for critical domains.openssl (enabled by default in Laravel).curl (for fetching remote chains if local resolution fails).openssl s_client or tools like SSL Labs).// app/Http/Middleware/ResolveSslChain.php
public function handle($request, Closure $next) {
$resolver = new \Spatie\SslCertificateChainResolver\Resolver();
$resolver->resolveForHost($request->getHost());
return $next($request);
}
Http::withOptions(['ssl' => true])).$client = new \Spatie\SslCertificateChainResolver\Guzzle\ClientDecorator(
new \GuzzleHttp\Client()
);
openssl or custom CA access. Workaround: Use a dedicated PHP process (e.g., Laravel Horizon) for resolution.openssl is enabled (e.g., AWS Lambda with custom runtime).Spatie\SslCertificateChainResolver\Exceptions\ChainNotResolved).[SSL_CHAIN] Failed to resolve chain for example.com: Missing intermediate CA: "DigiCert SHA2 Secure Server CA"
example.com is insecure due to missing intermediates")./ssl/debug) to inspect chain status for a given domain.$resolver->addCustomCertificatePath('/path/to/custom/ca-bundle.crt');
openssl calls.
$cache = new \Spatie\SslCertificateChainResolver\Cache\RedisCache(
new \Illuminate\Redis\Connections\Connection()
);
$resolver->setCache($cache);
| Failure Scenario | Impact | Mitigation |
|---|---|---|
openssl extension disabled |
All chain resolutions fail | Block deployment if extension_loaded('openssl') is false. |
| Unresolvable chain (e.g., private CA) | Insecure connections for users | Fallback to skip resolution or fail fast with user notification. |
| Cache stampede (Redis failure) | Increased openssl load |
Use local cache fallback (e.g., file-based). |
| Certificate revocation | MitM risk | Integrate with OCSP/CRL checks (complementary package like spatie/ssl-certificate-checker). |
openssl s_client.composer require spatie/ssl-certificate-chain-resolver.app/Http/Kernel.php.curl --insecure https://example.com).How can I help you explore Laravel packages today?