Validation & errors
ValidDomain is a Laravel validation rule for hostnames. The issue path runs it on every domain too, so invalid input never reaches a provider:
use RoundlyConsulting\Certificates\Rules\ValidDomain;
$request->validate(['domain' => ['required', new ValidDomain]]);
// Reject wildcards such as *.example.com
$request->validate(['domain' => ['required', new ValidDomain(allowWildcard: false)]]);
// Standalone checks
(new ValidDomain)->passes('shop.example.com'); // true
(new ValidDomain)->passes('https://shop.example.com'); // falseA valid hostname has at least two labels, each 1–63 letters, digits or inner hyphens, a non-numeric top-level label and at most 253 characters. Schemes, paths, ports, spaces and a trailing dot are rejected. A leading *. wildcard is allowed unless you pass allowWildcard: false.
Exceptions
Every package error extends CertificateException, so one catch covers them all:
| Exception | Raised when |
|---|---|
CertificateException | Base class. Also thrown for a domain with no registry row (renew(), renewLater(), revoke(), expire()), an illegal status move (renew(), renewLater(), revoke(), expire()), a provider that reports the certificate failed, expired or revoked, a renewal that produced the same certificate, a filesystem name with no stored PEM, PEM that is not an X.509 certificate, and when monitorExpiry() resolves no notifiable. |
InvalidDomainException | A domain failed ValidDomain during issuance. |
ProvisioningInProgressException | issue() while another process holds this certificate’s provisioning lock — nothing was provisioned and the row was not touched; retry once it finishes. |
UnknownProviderException | Certificates::driver() — or provider() on CertificateProviderManager — got an unknown driver name. |
AcmeException | An ACME step failed: directory, nonce, account, order, challenge, finalize, download, signing, key generation or an unsupported account key. |
KubernetesApiException | A Kubernetes API call failed (with the HTTP status and body) or the driver is misconfigured. |
use RoundlyConsulting\Certificates\Exceptions\CertificateException;
use RoundlyConsulting\Certificates\Exceptions\InvalidDomainException;
use RoundlyConsulting\Certificates\Exceptions\ProvisioningInProgressException;
use RoundlyConsulting\Certificates\Facades\Certificates;
try {
Certificates::for($domain)->using('acme')->issue();
} catch (InvalidDomainException $e) {
// a domain failed ValidDomain — nothing was recorded or requested
} catch (ProvisioningInProgressException $e) {
// another process is provisioning this certificate — the row was not touched, retry later
} catch (CertificateException $e) {
// any other package error: ACME, Kubernetes API, unknown driver,
// or a provider that reports the certificate failed, expired or revoked
}Show your open-source love
This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.
More ways to support, including cryptoBy donating, you agree to our donation terms.
Want this built into your product?
We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.