1. Go to this page and download the library: Download mbretter/acme2-library 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/ */
mbretter / acme2-library example snippets
use Karl\Acme2;
use Karl\Acme2\Resources;
$acme = new Acme2\Acme(); // without any args letsencrypt staging urls are used
$acme = new Acme2\Acme(true); // for letsencrypt production use
$acme = new Acme2\Acme('https://someca.example.com/acme'); // for any other acme compatible CA
$acme = new Acme2\Acme(true, $myHttpClient); // use your own http client
$acme = new Acme2\Acme();
$key = new Acme2\Key\RSA($pemKey);
$acme->setKey($key);
$account = new Resources\Account($acme)
$accountData = $account->lookup();
$acme = new Acme2\Acme();
$key = new Acme2\Key\RSA($pemKey);
$acme->setKey($key);
$accountData = $acme->account()->lookup();
...
$acme = new Acme2\Acme();
$key = new Acme2\Key\RSA(); // we use an RSA key
$key->generate();
$pem = $key->getPem(); // get the PEM, store your key somewhere
$acme->setKey($key); // acme needs a key to operate
$accountData = $acme->account()->create([
'termsOfServiceAgreed' => true,
'contact' => ['mailto:[email protected]']
]);
$kid = $accountData->url; // acme uses the account url as keyId
$acme = new Acme2\Acme();
$key = new Acme2\Key\RSA($pemKey);
$info = $acme->account()->lookup();
if ($info !== null)
{
$key->setKid($info->url); // account location is used as kid
}
$acme = new Acme2\Acme();
$key = new Acme2\Key\RSA($pemKey);
$acme->setKey($key);
$account = new Resources\Account($acme);
$account->deactivate($kid);
$acme = new Acme2\Acme();
$key = new Acme2\Key\RSA($pemKey);
$key->setKid($kid);
$acme->setKey($key);
$newOrder = $acme->order()->addIdentifier(null, 'acme01.example.com'); // create a new order object
$acme->order()->addIdentifier($newOrder, 'acme02.example.com'); // add another identifier
$orderData = $acme->order()->create($newOrder);
$orderUrl = $orderData->url; // store the orderUrl somewhere
...
$newOrder = $acme->order()->addIdentifier(null, '*.example.com');
$orderData = $acme->order()->create($newOrder);
$orderUrl = $orderData->url; // store the orderUrl somewhere
$order = new Acme2\Resources\Order($acme);
$orderData = $order->get($orderUrl);
print_r($orderData);
$orderData = $acme->order()->get($orderUrl);
foreach ($orderData->authorizations as $a)
{
$authData = $acme->authorization()->get($a);
printf("authorization for: %s\n", $authData->identifier->value);
$challengeData = $acme->authorization()->getChallenge($authData, 'dns-01');
if ($challengeData === null)
continue;
// you have to add the $authKey to the DNS TXT record
$authKey = $acme->challenge()->buildKeyAuthorization($challengeData);
printf("DNS auth key is: %s\n", $authKey);
// tell the CA to validate the challenge
$acme->challenge()->validate($challengeData->url);
$challengeData = $acme->authorization()->getChallenge($authData, 'http-01');
if ($challengeData === null)
continue;
// you have to put the $authKey to the well known path
$authKey = $acme->challenge()->buildKeyAuthorization($challengeData);
printf("HTTP auth key is: %s\n", $authKey);
// tell the CA to validate the challenge
$acme->challenge()->validate($challengeData->url);
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.