forked from yourivw/LEClient
-
Notifications
You must be signed in to change notification settings - Fork 6
/
exampleDNSInit.php
33 lines (31 loc) · 1.5 KB
/
exampleDNSInit.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
//Sets the maximum execution time to two minutes, to be sure.
ini_set('max_execution_time', 120);
// Including the LetsEncrypt Client.
require_once('LEClient/LEClient.php');
// Listing the contact information in case a new account has to be created.
$email = array('[email protected]');
// Defining the base name for this order
$basename = 'example.org';
// Listing the domains to be included on the certificate
$domains = array('example.org', 'test.example.org');
// Initiating the client instance. In this case using the staging server (argument 2) and outputting all status and debug information (argument 3).
$client = new LEClient($email, true, LECLient::LOG_STATUS);
// Initiating the order instance. The keys and certificate will be stored in /example.org/ (argument 1) and the domains in the array (argument 2) will be on the certificate.
$order = $client->getOrCreateOrder($basename, $domains);
// Check whether there are any authorizations pending. If that is the case, try to verify the pending authorizations.
if(!$order->allAuthorizationsValid())
{
// Get the DNS challenges from the pending authorizations.
$pending = $order->getPendingAuthorizations(LEOrder::CHALLENGE_TYPE_DNS);
// Walk the list of pending authorization DNS challenges.
if(!empty($pending))
{
foreach($pending as $challenge)
{
// For the purpose of this example, a fictitious functions creates or updates the ACME challenge DNS record for this domain.
setDNSRecord($challenge['identifier'], $challenge['DNSDigest'])
}
}
}
?>