Kelunik\AcmeClient\Stores\KeyStore::put PHP Method

put() public method

public put ( $path, KeyPair $keyPair )
$keyPair Kelunik\Acme\KeyPair
    public function put($path, KeyPair $keyPair)
    {
        if (!is_string($path)) {
            throw new InvalidArgumentException(sprintf("\$root must be of type string, %s given.", gettype($path)));
        }
        return \Amp\resolve($this->doPut($path, $keyPair));
    }

Usage Example

Beispiel #1
0
 public function doExecute(Manager $args)
 {
     $email = $args->get("email");
     (yield \Amp\resolve($this->checkEmail($email)));
     $server = \Kelunik\AcmeClient\resolveServer($args->get("server"));
     $keyFile = \Kelunik\AcmeClient\serverToKeyname($server);
     $path = "accounts/{$keyFile}.pem";
     $bits = 4096;
     $keyStore = new KeyStore(\Kelunik\AcmeClient\normalizePath($args->get("storage")));
     $this->climate->br();
     try {
         $keyPair = (yield $keyStore->get($path));
         $this->climate->whisper("    Using existing private key ...");
     } catch (KeyStoreException $e) {
         $this->climate->whisper("    No private key found, generating new one ...");
         $keyPair = (new OpenSSLKeyGenerator())->generate($bits);
         $keyPair = (yield $keyStore->put($path, $keyPair));
         $this->climate->whisper("    Generated new private key with {$bits} bits.");
     }
     $acme = $this->acmeFactory->build($server, $keyPair);
     $this->climate->whisper("    Registering with " . substr($server, 8) . " ...");
     /** @var Registration $registration */
     $registration = (yield $acme->register($email));
     $this->climate->info("    Registration successful. Contacts: " . implode(", ", $registration->getContact()));
     $this->climate->br();
     (yield new CoroutineResult(0));
 }
All Usage Examples Of Kelunik\AcmeClient\Stores\KeyStore::put