LetsEncrypt client library for ACME v2

1.0.0-beta2 2020-03-26 13:40 UTC

This package is auto-updated.

Last update: 2024-04-09 00:11:11 UTC


Build Status Code Coverage Code Quality Packagist Version

ACME v2 draft


Use Composer to install the package:

composer require misantron/letsencrypt-client

Basic usage

Create client instance with defaults:

use LetsEncrypt\Client;

$client = new Client($accountKeysPath, $certificatesPath);

By default client uses api staging environment.
To switch to production mode you can pass third argument to client constructor with false value:

use LetsEncrypt\Client;

$client = new Client($accountKeysPath, $certificatesPath, false);

Account methods

  • $client->account()->create(array $emails)
  • $client->account()->get()
  • $client->account()->getOrCreate(array $emails)
  • $client->account()->update(array $emails)
  • $client->account()->keyRollover()
  • $client->account()->deactive()

Order methods

  • $client->order()->create(Account $account, string $basename, array $subjects, Certificate $certificate)
  • $client->order()->get(Account $account, string $basename, array $subjects, KeyType $keyType)
  • $client->order()->getOrCreate(Account $account, string $basename, array $subjects, Certificate $certificate)
  • $client->order()->getPendingHttpAuthorizations(Account $account, Order $order)
  • $client->order()->getPendingDnsAuthorizations(Account $account, Order $order)
  • $client->order()->verifyPendingHttpAuthorizations(Account $account, Order $order, string $identifier)
  • $client->order()->verifyPendingDnsAuthorizations(Account $account, Order $order, string $identifier)
  • $client->order()->getCertificate(Account $account, Order $order, string $basename, KeyType $keyType)
  • $client->order()->getCertificateContent(string $basename, KeyType $keyType)
  • $client->order()->getCertificateExpirationDate(string $basename, KeyType $keyType)
  • $client->order()->revokeCertificate(Account $account, string $basename, KeyType $keyType, RevocationReason $reason)

Advanced usage


If you need to get some debug information or analyze server interaction

use LetsEncrypt\Client;                       
use LetsEncrypt\Logger\Logger;
use LetsEncrypt\Logger\LogStrategy;

$strategy = LogStrategy::errorsOnly();
// $logger is an instance of PSR-3 logger (\Psr\Log\LoggerInterface)
$clientLogger = new Logger($logger, $strategy);
$client = new Client($accountKeysPath, $certificatesPath, true, $clientLogger);

Logger strategy

  • LogStrategy::requestsOnly() log only requests data
  • LogStrategy::errorsOnly() log only failed (400/500) requests (request/response data)
  • LogStrategy::debugMode() log all requests (request/response data)