1. Go to this page and download the library: Download rogierw/rw-acme-client library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
rogierw / rw-acme-client example snippets
$localAccount = new \Rogierw\RwAcme\Support\LocalFileAccount(__DIR__.'/__account');
$client = new Api(localAccount: $localAccount);
$client = new Api();
// Do some stuff.
$localAccount = new \Rogierw\RwAcme\Support\LocalFileAccount(__DIR__.'/__account');
$client->setLocalAccount($localAccount);
if (! $client->account()->exists()) {
$account = $client->account()->create();
}
// Or get an existing account.
$account = $client->account()->get();
$order = $client->order()->new($account, ['example.com']);
// Optionally request a specific ACME profile, if the ACME server supports it.
$order = $client->order()->new($account, ['example.com'], 'tlsserver');
// Get the data for the HTTP challenge; filename and content.
$validationData = $client->domainValidation()->getValidationData($validationStatus, \Rogierw\RwAcme\Enums\AuthorizationChallengeEnum::HTTP);
// Get the data for the DNS challenge.
$validationData = $client->domainValidation()->getValidationData($validationStatus, \Rogierw\RwAcme\Enums\AuthorizationChallengeEnum::DNS);
try {
$client->domainValidation()->start($account, $validationStatus[0], \Rogierw\RwAcme\Enums\AuthorizationChallengeEnum::HTTP);
} catch (DomainValidationException $exception) {
// The local HTTP challenge test has been failed...
}
try {
$client->domainValidation()->start($account, $validationStatus[0], \Rogierw\RwAcme\Enums\AuthorizationChallengeEnum::DNS);
} catch (DomainValidationException $exception) {
// The local DNS challenge test has been failed...
}
$privateKey = \Rogierw\RwAcme\Support\OpenSsl::generatePrivateKey(key_type: OPENSSL_KEYTYPE_RSA);
// ^- you can switch "key_type: OPENSSL_KEYTYPE_EC" to generate a ECDSA key and certificate instead of RSA
$csr = \Rogierw\RwAcme\Support\OpenSsl::generateCsr(['example.com'], $privateKey);
if ($order->isReady() && $client->domainValidation()->allChallengesPassed($order)) {
$client->order()->finalize($order, $csr);
}
if ($order->isFinalized()) {
$certificateBundle = $client->certificate()->getBundle($order);
}
if ($order->isValid()) {
$client->certificate()->revoke($certificateBundle->fullchain);
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.