Sinetex.Identity (sinetex v0.1.0)

Copy Markdown View Source

Your own certificate and its RSA private key.

An identity signs what you send (from: in Sinetex.seal/2) and decrypts what you receive (as: in Sinetex.open/2).

The private key is loaded from PEM (PKCS#1 or PKCS#8, optionally encrypted) or DER. Keeping the key safe (HSM, vault, file permissions) is up to the caller. The struct does not show the key when inspected.

Summary

Functions

Loads a certificate and its private key.

Types

load_error()

@type load_error() ::
  Sinetex.Certificate.load_error() | :invalid_private_key | :key_mismatch

t()

@type t() :: %Sinetex.Identity{
  certificate: Sinetex.Certificate.t(),
  private_key: :public_key.rsa_private_key()
}

Functions

load(cert, key, opts \\ [])

@spec load(binary(), binary(), keyword()) :: {:ok, t()} | {:error, load_error()}

Loads a certificate and its private key.

Both are binaries in PEM or DER. The certificate goes through the checks of Sinetex.Certificate.load/2, and the key must match the certificate.

Options

Examples

{:ok, me} = Sinetex.Identity.load(File.read!("me.pem"), File.read!("me.key"))
{:ok, me} = Sinetex.Identity.load(cert, key, pc: 0x06, password: "secret")