Certbot v0.5.1 Certbot.Certificate View Source
The module provides utility functions to deal with the serial and validity timestamps of a certificate as well as being a struct to store certificate/keys
Link to this section Summary
Functions
Build struct to store a certificate in der format and its private key
Get hexadecimal serial number of the certicate
Get integer serial number of the certicate
Get DateTime of the date the certificate was given out
Get DateTime of the date the certificate will be valid until
Link to this section Types
Link to this section Functions
build(cert, arg)
View Sourcebuild(binary(), {:ECPrivateKey, binary()} | {:RSAPrivateKey, binary()}) :: Certbot.Certificate.t()
Build struct to store a certificate in der format and its private key
For example, to generate a
cert_file = File.read!("priv/cert/selfsigned.pem")
key_file = File.read!("priv/cert/selfsigned_key.pem")
[certificate] = :public_key.pem_decode(cert_file)
cert = :public_key.pem_entry_decode(certificate)
cert = :public_key.der_encode(:Certificate, cert)
[key] = :public_key.pem_decode(key_file)
key = :public_key.pem_entry_decode(key)
der_key = :public_key.der_encode(:RSAPrivateKey, key)
Certbot.Certificate.build(cert, {:RSAPrivateKey, der_key})
hex_serial(cert)
View Sourcehex_serial(Certbot.Certificate.t()) :: String.t()
Get hexadecimal serial number of the certicate
This is what is visible when inspecting a certificate in the browser
Example
iex> Certbot.Certificate.hex_serial(build_certificate())
"FC100FFC200BF62F"
serial(certificate)
View Sourceserial(Certbot.Certificate.t()) :: non_neg_integer()
Get integer serial number of the certicate
iex> Certbot.Certificate.serial(build_certificate())
18163034872729040431
valid_from(certificate)
View Sourcevalid_from(Certbot.Certificate.t()) :: DateTime.t()
Get DateTime of the date the certificate was given out
Example
iex> Certbot.Certificate.valid_from(build_certificate())
~U[2019-07-09 00:00:00Z]
valid_until(certificate)
View Sourcevalid_until(Certbot.Certificate.t()) :: DateTime.t()
Get DateTime of the date the certificate will be valid until
Example
iex> Certbot.Certificate.valid_until(build_certificate())
~U[2020-07-09 00:00:00Z]