ExAcme.RevocationBuilder (ExAcme v0.5.2)
View SourceProvides functionality to build ACME certificate revocation requests.
Use this module to construct a revocation request by supplying the certificate in one of several formats
(X509.Certificate
struct, DER binary, or PEM string) and an optional revocation reason.
Attributes
certificate
- The DER-encoded certificate to revokereason
- The revocation reason
Summary
Functions
Sets the certificate for revocation using an X509 certificate struct, DER binary, or PEM string.
Creates a new revocation builder.
Sets the revocation reason.
Converts the revocation builder to a map.
Types
Functions
@spec certificate(t(), certificate: X509.Certificate.t(), der: binary(), pem: binary() ) :: t()
Sets the certificate for revocation using an X509 certificate struct, DER binary, or PEM string.
Parameters
revocation
: The current revocation builder.certificate
: Keyword with one of the following options:certificate
: AnX509.Certificate
struct representing the certificate to revoke.der
: A DER-encoded binary of the certificate to revoke.pem
: A PEM-encoded string of the certificate to revoke.
Returns
- An updated
ExAcme.RevocationBuilder
struct with the certificate set.
Examples
# Using a certificate struct
iex> cert = X509.Certificate.self_signed(X509.PrivateKey.new_ec(:secp256r1), "/CN=example.com")
iex> revocation = ExAcme.RevocationBuilder.new_revocation()
iex> |> ExAcme.RevocationBuilder.certificate(certificate: cert)
# Using a PEM string
iex> pem = File.read!("path/to/certificate.pem")
iex> revocation = ExAcme.RevocationBuilder.new_revocation()
iex> |> ExAcme.RevocationBuilder.certificate(pem: pem)
# Using a DER binary
iex> der = File.read!("path/to/certificate.der")
iex> revocation = ExAcme.RevocationBuilder.new_revocation()
iex> |> ExAcme.RevocationBuilder.certificate(der: der)
@spec new_revocation() :: t()
Creates a new revocation builder.
Returns
- A new
ExAcme.RevocationBuilder
struct with no certificate or reason set.
Sets the revocation reason.
Accepts either a named reason or a numeric reason code as defined in RFC 5280.
Parameters
revocation
: The current revocation builder.reason
: An atom representing the reason (:unspecified
,:key_compromise
,:affiliation_changed
,:superseded
, or:cessation_of_operation
) or an integer code.
Returns
- An updated
ExAcme.RevocationBuilder
struct with the reason set.
Examples
# Using a named reason
iex> revocation = ExAcme.RevocationBuilder.new_revocation()
iex> revocation = ExAcme.RevocationBuilder.reason(revocation, :key_compromise)
iex> revocation.reason
1
# Using a numeric reason code
iex> revocation = ExAcme.RevocationBuilder.new_revocation()
iex> revocation = ExAcme.RevocationBuilder.reason(revocation, 4)
iex> revocation.reason
4
Converts the revocation builder to a map.
Removes any keys with nil values and converts all keys to camelCase for API compatibility.
Parameters
revocation
: The revocation builder struct.
Returns
- A map representing the revocation request.