LetsEncrypt client library for ACME v2 written in PHP.
This library is inspired by yourivw/LEClient, completely rewritten and enhanced with some new features:
The aim of this client is to make an easy-to-use and integrated solution to create a LetsEncrypt-issued SSL/TLS certificate with PHP.
You have the possibility to use the HTTP authentication: You need to be able to redirect specific requests (see below)
You have also the possibility to use DNS authentication: You need to be able to set dynamic DNS configurations.
Wildcard certificates can only be requested by using the dns authentication.
Tested with LetsEncrypt staging and production servers.
This library supports it to set a preferred chain in Order::setPreferredChain($issuerCN))
.
If the preferred chain is not set or set to IdenTrust’s chain, this library will try to use the IdenTrust’s chain as long as possible. Please see: https://letsencrypt.org/docs/dst-root-ca-x3-expiration-september-2021/
The minimum required PHP version is 7.3.
This client also depends on cURL and OpenSSL.
Install via composer:
composer require fbett/le_acme2
Also have a look at the LetsEncrypt documentation for more information and documentation on LetsEncrypt and ACME.
mkdir /etc/ssl/le-storage/
chown root:root /etc/ssl/le-storage
chmod 0600 /etc/ssl/le-storage
mkdir /var/www/acme-challenges
Example apache virtual host configuration:
<VirtualHost ...>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule \.well-known/acme-challenge/(.*)$ https://your-domain.com/path/to/acme-challenges/$1 [R=302,L]
</IfModule>
</VirtualHost>
If DNSWriter::write(...)
is called, set the DNS configuration like described in:
https://letsencrypt.org/docs/challenge-types/#dns-01-challenge
(By adding the digest as a TXT record for the subdomain '_acme-challenge'.)
if($order->isCertificateBundleAvailable()) {
$bundle = $order->getCertificateBundle();
$pathToPrivateKey = $bundle->path . $bundle->private;
$pathToCertificate = $bundle->path . $bundle->certificate;
$pathToIntermediate = $bundle->path . $bundle->intermediate;
$order->enableAutoRenewal(); // If the date of expiration is closer than thirty days, the order will automatically start the renewal process.
}
If a certificate is renewed, the path will also change.
My integrated workflow is the following:
Please take a look on the Samples for a full sample workflow.
This project is licensed under the MIT License - see the LICENSE.md file for details.