# `Sinetex.Identity`
[🔗](https://github.com/openspb/sinetex/blob/v0.1.0/lib/sinetex/identity.ex#L1)

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.

# `load_error`

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

# `t`

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

# `load`

```elixir
@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

  * `:pc` - see `Sinetex.Certificate.load/2`.
  * `:password` - password of an encrypted PEM key.

## 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")

---

*Consult [api-reference.md](api-reference.md) for complete listing*
