High level ACME client.

author Niklas Keller
package Kelunik\Acme

 Methods

AcmeService constructor.

__construct(\Kelunik\Acme\AcmeClient $acmeClient, \Kelunik\Acme\KeyPair $accountKeyPair) 
API
api

Parameters

$acmeClient

\Kelunik\Acme\AcmeClient

ACME client

$accountKeyPair

\Kelunik\Acme\KeyPair

account key pair

Answers a challenge and signals that the CA should validate it.

answerChallenge(string $location, string $keyAuth) : \Amp\Promise
API
api

Parameters

$location

string

URI of the challenge

$keyAuth

string

key authorization

Exceptions

\Kelunik\Acme\AcmeException If something went wrong.

Returns

\Amp\Promiseresolves to the decoded JSON response

Generates the payload which must be provided in HTTP-01 challenges.

generateHttp01Payload(string $token) : string
API
api

Parameters

$token

string

challenge token

Exceptions

\Kelunik\Acme\AcmeException If something went wrong.

Returns

stringpayload to be provided at /.well-known/acme-challenge/$token

Polls for a certificate.

pollForCertificate(string $location) : \Amp\Promise
API
api

Parameters

$location

string

URI of the certificate

Exceptions

\Kelunik\Acme\AcmeException If something went wrong.

Returns

\Amp\Promiseresolves to the complete certificate chain as array of PEM encoded certificates

Polls until a challenge has been validated.

pollForChallenge(string $location) : \Amp\Promise
API
api

Parameters

$location

string

URI of the challenge

Exceptions

\Kelunik\Acme\AcmeException

Returns

\Amp\Promiseresolves to null

Registers a new account on the server.

register(string $email, string|null $agreement = null) : \Amp\Promise
API
api

Parameters

$email

string

e-mail address for contact

$agreement

stringnull

agreement URI or null if not agreed yet

Exceptions

\Kelunik\Acme\AcmeException If something went wrong.

Returns

\Amp\Promiseresolves to a Registration object

Requests a new certificate.

requestCertificate(\Kelunik\Acme\KeyPair $keyPair, array $domains) : \Amp\Promise
API
api

Parameters

$keyPair

\Kelunik\Acme\KeyPair

domain key pair

$domains

array

domains to include in the certificate (first will be used as common name)

Exceptions

\Kelunik\Acme\AcmeException If something went wrong.

Returns

\Amp\Promiseresolves to the URI where the certificate will be provided

Requests challenges for a given DNS name.

requestChallenges(string $dns) : \Amp\Promise
API
api

Parameters

$dns

string

DNS name to request challenge for

Exceptions

\Kelunik\Acme\AcmeException If something went wrong.

Returns

\Amp\Promiseresolves to an array of challenges

Revokes a certificate.

revokeCertificate(string $pem) : \Amp\Promise
API
api

Parameters

$pem

string

PEM encoded certificate

Exceptions

\Kelunik\Acme\AcmeException If something went wrong.

Returns

\Amp\Promiseresolves to true

Verifies a HTTP-01 challenge.

selfVerify(string $domain, string $token, string $payload) : \Amp\Promise
API

Can be used to verify a challenge before requesting validation from a CA to catch errors early.

api

Parameters

$domain

string

domain to verify

$token

string

challenge token

$payload

string

expected payload

Exceptions

\Kelunik\Acme\AcmeException If the challenge could not be verified.

Returns

\Amp\Promiseresolves to null