kelunik/certificate
Generate and manage X.509 certificates in PHP with a simple API. Create CSRs, self-signed and CA-signed certs, handle keys and certificate chains, and export common formats—ideal for TLS tooling, service provisioning, and automation.
Install via Composer: composer require kelunik/certificate. Start by parsing a certificate from a PEM string or file:
use function Kelunik\Certificate\parseCertificate;
$cert = parseCertificate(file_get_contents('cert.pem'));
The returned Certificate object provides methods like $cert->getSubject(), $cert->getIssuer(), $cert->getValidFrom(), $cert->getValidTo(), and $cert->getSubjectAltNames(). The simplest first use case is checking expiration:
if ($cert->isValidAt(new DateTime())) {
echo "Certificate is currently valid.\n";
}
Review the README and src/ in the repository for full class/method signatures—no external config needed.
openssl s_client output or cert files), alert on expiry, and generate reports.keyUsage includes digitalSignature).$cert->getPublicKey()->getFingerprint('sha256').parseCertificate() with embedded PEM test strings to validate logic paths.openssl_verify() externally if chain trust is required.getValidTo() returns a DateTimeImmutable; compare with DateTimeImmutable to avoid type issues.getSubjectAltNames() may be empty if SANs aren’t present—check getSubject()->commonName as fallback (but don’t rely on it).Kelunik\Certificate\CertificateException—always wrap parseCertificate() in try/catch.How can I help you explore Laravel packages today?