Acmex v0.1.2 Acmex View Source
This module provides the main API to interface with Acme.
Link to this section Summary
Functions
Finalizes the order.
Gets an existing account.
Gets the certificate.
Gets an existing challenge.
Gets the challenge response.
Gets an existing order.
Creates a new account.
Creates a new order.
Revokes a certificate.
Starts the client with a private key.
Validates the challenge.
Link to this section Types
account_reply()
View Sourceaccount_reply() :: {:ok, Acmex.Resource.Account.t()} | {:error, HTTPoison.Response.t()}
certificate_reply()
View Sourcecertificate_reply() :: {:ok, String.t()} | {:error, HTTPoison.Response.t()}
certificate_revocation_reply()
View Sourcecertificate_revocation_reply() :: :ok | {:error, HTTPoison.Response.t()}
challenge_reply()
View Sourcechallenge_reply() :: {:ok, Acmex.Resource.Challenge.t()} | {:error, HTTPoison.Response.t()}
order_reply()
View Sourceorder_reply() :: {:ok, Acmex.Resource.Order.t()} | {:error, HTTPoison.Response.t()}
Link to this section Functions
finalize_order(order, csr)
View Sourcefinalize_order(Acmex.Resource.Order.t(), String.t()) :: challenge_reply()
Finalizes the order.
Parameters
- order: The order resource with status "pending".
Examples
iex> Acmex.finalize_order(%Order{status: "pending"})
{:ok, %Order{status: "processing"}}
Gets an existing account.
An account will only be returned if the current private key has been used to create a new account.
Examples
iex> Acmex.get_account()
{:ok, %Account{...}}
get_certificate(order)
View Sourceget_certificate(Acmex.Resource.Order.t()) :: certificate_reply()
Gets the certificate.
The format of the certificate is application/pem-certificate-chain.
Parameters
- order: The order resource with status "valid".
Examples
iex> Acmex.get_certificate(%Order{status: "valid"})
{:ok, "-----BEGIN CERTIFICATE-----..."}
Gets an existing challenge.
Parameters
- url: The url attribute of the challenge resource.
Examples
iex> Acmex.get_challenge(%Challenge{...}.url)
{:ok, %Challenge{...}}
get_challenge_response(challenge)
View Sourceget_challenge_response(Acmex.Resource.Challenge.t()) :: {:ok, map()}
Gets the challenge response.
Parameters
- challenge: The challenge resource.
Examples
iex> Acmex.get_challenge_response(%Challenge{token: "bZxymov025OYA4DkGSI5XPKdAW9V93eKoDZZ56AC3cI", type: "dns-01"})
{:ok,
%{
key_authorization: "AgemQZ-WIft7VwWljRb3l_nkyigEILfRzzx5E6HdFyY",
record_name: "_acme-challenge",
record_type: "TXT"
}}
iex> Acmex.get_challenge_response(%Challenge{token: "oR3Xwj4GgXIxUtKMUfmVf4hmRFehAIgSsg7oXD_PCEw", type: "http-01"})
{:ok,
%{
content_type: "text/plain",
filename: ".well-known/acme-challenge/oR3Xwj4GgXIxUtKMUfmVf4hmRFehAIgSsg7oXD_PCEw",
key_authorization: "oR3Xwj4GgXIxUtKMUfmVf4hmRFehAIgSsg7oXD_PCEw.5zmJUVWaucybUNJSLeCaO9D_cauS5QiwA92KTiY_vNc"
}}
Gets an existing order.
Parameters
- url: The url attribute of the order resource.
Examples
iex> Acmex.get_order(%{Order}.url)
{:ok, %Order{...}}
new_account(contact, tos)
View Sourcenew_account([String.t()], boolean()) :: account_reply()
Creates a new account.
Parameters
- contact: A list of URLs that the ACME can use to contact the client for issues related to this account.
- tos: Terms Of Service Agreed indicates the client's agreement with the terms of service.
Examples
iex> Acmex.new_account(["mailto:info@example.com"], true)
{:ok, %Account{...}}
Creates a new order.
Parameters
- identifiers: A list of domains.
Examples
iex> Acmex.new_order(["example.com"])
{:ok, %Order{...}}
revoke_certificate(certificate, reason_code \\ 0)
View Sourcerevoke_certificate(String.t(), integer()) :: certificate_revocation_reply()
Revokes a certificate.
Parameters
- certificate: The certificate to be revoked.
- reason: Optional revocation reason code.
Examples
iex> Acmex.revoke_certificate("-----BEGIN CERTIFICATE-----...", 0)
:ok
Starts the client with a private key.
If the private key path does not exists, the client will not start.
Parameters
- keyfile: The path to an RSA key.
- name: Optional name for the Client.
Examples
iex> Acmex.start_link(keyfile: "test/support/fixture/account.key")
{:ok, #PID<...>}
iex> Acmex.start_link(key: "-----BEGIN RSA PRIVATE KEY-----...", name: :acmex_optional_name)
{:ok, #PID<...>}
validate_challenge(challenge)
View Sourcevalidate_challenge(Acmex.Resource.Challenge.t()) :: challenge_reply()
Validates the challenge.
Parameters
- challenge: The challenge resource.
Examples
iex> Acmex.validate_challenge(%Challenge{...})
{:ok, %Challenge{...}}