Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Ssl Certificate

Ssl Certificate Laravel Package

spatie/ssl-certificate

Retrieve and validate SSL/TLS certificates for any host in PHP. This package fetches certificate details like issuer, validity dates, and expiration status, making it easy to monitor domains and detect upcoming certificate issues in Laravel apps.

View on GitHub
Deep Wiki
Context7

A class to validate SSL certificates

Frequently asked questions about Ssl Certificate
How do I install and use spatie/ssl-certificate in a Laravel project?
Install via Composer with `composer require spatie/ssl-certificate`, then use `SslCertificate::createForHostName('example.com')` to fetch and validate certificates. The package requires the PHP OpenSSL extension, which is enabled by default in Laravel.
Does this package support checking certificates for IPv6 addresses?
Yes, the package supports IPv6 addresses. Use `SslCertificate::createForHostName('example.com', 443, 'ipv6')` to explicitly target IPv6. Test thoroughly in your environment, especially if behind proxies like Cloudflare.
Can I validate certificates for non-standard ports (e.g., 8443) or custom socket contexts?
Yes, pass the port as the second argument: `SslCertificate::createForHostName('example.com', 8443)`. For custom socket contexts (e.g., proxies), use the `createForHostName` method with a `stream_context_create` array as the fourth parameter.
How do I handle self-signed certificates or certificates from untrusted CAs?
The package doesn’t validate CA trust by default. Use `openssl_verify()` or `openssl_x509_checkpurpose()` in a wrapper to check trust. Log warnings for self-signed certs (common in staging) or disable verification with `$verifyCertificate = false` in `createForHostName`.
Is there a way to cache certificate results to avoid repeated network calls?
Yes, cache results using Laravel’s cache or Redis. Store the certificate data (e.g., `toArray()`) and refresh it periodically via a scheduled job. Example: `Cache::remember('cert_example_com', now()->addHours(1), fn() => SslCertificate::createForHostName('example.com'))`.
How can I integrate this with Laravel’s scheduling for daily certificate checks?
Create an Artisan command (e.g., `php artisan certificate:check`) and schedule it in `app/Console/Kernel.php` with `$schedule->command('certificate:check')->daily()`. Use the package’s methods like `daysUntilExpirationDate()` to trigger alerts when certificates expire soon.
Does this package support wildcard certificates (e.g., *.example.com)?
Yes, the package handles wildcard certificates automatically. Use `createForHostName('*.example.com')` to validate them. The `getSubject()` method will return the full subject, including wildcards, for further processing if needed.
How do I test this package in a Laravel project with mocked network responses?
Mock `stream_socket_client()` in your tests to avoid flaky network calls. Use Pest or PHPUnit to simulate certificate responses, including edge cases like expired or self-signed certs. Test against `badssl.com` for real-world scenarios.
Are there alternatives to spatie/ssl-certificate for Laravel?
Alternatives include `paragonie/easy-pki` (for PKI tasks) or `phpseclib/phpseclib` (for low-level SSL checks). However, Spatie’s package is Laravel-optimized, lightweight, and focused on certificate validation with a fluent interface, making it ideal for most use cases.
How do I extend this package to validate OCSP stapling or CRL checks?
The package doesn’t include OCSP/CRL checks, but you can extend it by adding custom methods. Use PHP’s `openssl_crl_match()` or `openssl_ocsp_check()` functions in a wrapper class. Example: Create a `CertificateValidator` facade that extends `SslCertificate` with these checks.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codraw/framework-extra-bundle
codraw/messenger
codraw/security
codraw/mailer
codraw/contracts
codraw/profiling
codraw/dependency-injection
codraw/tester
codraw/core
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony