Kelunik\Acme\AcmeService::revokeCertificate PHP Méthode

revokeCertificate() public méthode

Revokes a certificate.
public revokeCertificate ( string $pem ) : Amp\Promise
$pem string PEM encoded certificate
Résultat Amp\Promise resolves to true
    public function revokeCertificate($pem)
    {
        return \Amp\resolve($this->doRevokeCertificate($pem));
    }

Usage Example

Exemple #1
0
 private function doExecute(Manager $args) : Generator
 {
     if (posix_geteuid() !== 0) {
         throw new AcmeException("Please run this script as root!");
     }
     $server = $args->get("server");
     $protocol = substr($server, 0, strpos("://", $server));
     if (!$protocol || $protocol === $server) {
         $server = "https://" . $server;
     } elseif ($protocol !== "https") {
         throw new \InvalidArgumentException("Invalid server protocol, only HTTPS supported");
     }
     $keyPair = $this->checkRegistration($args);
     $acme = new AcmeService(new AcmeClient($server, $keyPair), $keyPair);
     $this->logger->info("Revoking certificate ...");
     $pem = (yield get($args->get("cert")));
     $cert = new Certificate($pem);
     if ($cert->getValidTo() < time()) {
         $this->logger->warning("Certificate did already expire, no need to revoke it.");
         return;
     }
     $this->logger->info("Certificate was valid for: " . implode(", ", $cert->getNames()));
     (yield $acme->revokeCertificate($pem));
     $this->logger->info("Certificate has been revoked.");
 }