DirectAdmin\LetsEncrypt\Lib\Account::loadKeys PHP Method

loadKeys() public method

Check if keys exists, and when they does load keys into local variables.
public loadKeys ( ) : boolean
return boolean
    public function loadKeys()
    {
        if (!$this->existsInStorage('public.key') || !$this->existsInStorage('private.key')) {
            return false;
        } else {
            $publicKey = $this->getFromStorage('public.key');
            $privateKey = $this->getFromStorage('private.key');
            $this->keyPair = new KeyPair($privateKey, $publicKey);
            $this->acme = new AcmeService(new AcmeClient($this->acmeServer, $this->keyPair), $this->keyPair);
            return true;
        }
    }

Usage Example

Exemplo n.º 1
0
$users = scandir($usersPath);
// Loop through all users
foreach ($users as $user) {
    // Check if it's not some junk thingy
    if (in_array($user, ['.', '..']) || empty($user)) {
        continue;
    }
    // Create account object
    $account = new Account($user, null, $config->config('server'));
    // Is there a config file present?
    if (!$account->existsInStorage('config.json')) {
        $log->log('Skipped user ' . $account->getUsername());
        continue;
    }
    $log->log('Processing user ' . $account->getUsername());
    if (!$account->loadKeys()) {
        $log->log('No keys present at user ' . $account->getUsername());
        continue;
    }
    $account->setEmail($account->config('email'));
    // Get all domains of the user
    $domains = file_get_contents($usersPath . DIRECTORY_SEPARATOR . $account->getUsername() . DIRECTORY_SEPARATOR . 'domains.list');
    // Loop through all domains of the user
    foreach (explode("\n", $domains) as $domain) {
        if (empty($domain)) {
            continue;
        }
        // Replace the $domain with our Domain object,
        $domain = new Domain($domain, $account);
        if (!$domain->existsInStorage('config.json')) {
            $log->log('Skipped domain ' . $domain->getDomain());