ex_openssl v0.1.3 ExOpenssl.PKey

Private Key Handling

Link to this section Summary

Types

Pem encoded certificate string

Functions

Read Key from Pem String

Link to this section Types

Link to this opaque

key() (opaque)
key()

Link to this type

pem()
pem() :: String.t()

Pem encoded certificate string.

Link to this section Functions

Link to this function

from_pem(pem)
from_pem(pem :: pem()) ::
  {:ok, key()} | {:error, [ExOpenssl.Errors.Error.t()]}

Read Key from Pem String

Examples

iex> PKey.from_pem(File.read!("priv/test/key.pem"))
{:ok, #Reference<0.2767117777.4010409990.249887>}

iex> PKey.from_pem(File.read!("priv/test/bad_key.pem"))
{:error,
 [%ExOpenssl.Errors.Error{code: 218570907, data: nil,
   file: "crypto/asn1/asn1_lib.c", function: "ASN1_get_object",
   library: "asn1 encoding routines", line: 91, reason: nil},
  %ExOpenssl.Errors.Error{code: 218529894, data: nil,
   file: "crypto/asn1/tasn_dec.c", function: "asn1_check_tlen",
   library: "asn1 encoding routines", line: 1100,
   reason: "MISSING_EQUAL_SIGN"},
  %ExOpenssl.Errors.Error{code: 218595386, data: "Type=X509",
   file: "crypto/asn1/tasn_dec.c", function: "asn1_item_embed_d2i",
   library: "asn1 encoding routines", line: 274, reason: nil},
  %ExOpenssl.Errors.Error{code: 151416845, data: nil,
   file: "crypto/pem/pem_oth.c", function: "PEM_ASN1_read_bio",
   library: "PEM routines", line: 33,
   reason: "configuration file routines"}]}
Link to this function

from_pem!(arg1)
from_pem!(pem :: pem()) :: key() | no_return()

See from_pem/1