I tried your code in iex
.
What I do get there is this:
** (MatchError) no match of right hand side value: {:error, %MatchError{term: {:error, {:asn1, {{:unexpected, [{2, <<1, 0, 1>>}]}, [{:"OTP-PUB-KEY", :dec_RSAPublicKey, 2, [file: 'OTP-PUB-KEY.erl', line: 2552]}, {:"OTP-PUB-KEY", :decode, 2, [file: 'OTP-PUB-KEY.erl', line: 1103]}, {:public_key, :der_decode, 2, [file: 'public_key.erl', line: 249]}, {ExPublicKey, :load_pem_entry, 2, [file: 'lib/ex_public_key.ex', line: 122]}, {ExPublicKey, :loads, 2, [file: 'lib/ex_public_key.ex', line: 94]}, {:erl_eval, :do_apply, 6, [file: 'erl_eval.erl', line: 677]}, {:erl_eval, :expr, 5, [file: 'erl_eval.erl', line: 446]}, {:elixir, :eval_forms, 4, [file: 'src/elixir.erl', line: 233]}]}}}}, [{:public_key, :der_decode, 2, [file: 'public_key.erl', line: 253]}, {ExPublicKey, :load_pem_entry, 2, [file: 'lib/ex_public_key.ex', line: 122]}, {ExPublicKey, :loads, 2, [file: 'lib/ex_public_key.ex', line: 94]}, {:erl_eval, :do_apply, 6, [file: 'erl_eval.erl', line: 677]}, {:erl_eval, :expr, 5, [file: 'erl_eval.erl', line: 446]}, {:elixir, :eval_forms, 4, [file: 'src/elixir.erl', line: 233]}, {IEx.Evaluator, :handle_eval, 5, [file: 'lib/iex/evaluator.ex', line: 250]}, {IEx.Evaluator, :do_eval, 3, [file: 'lib/iex/evaluator.ex', line: 230]}]}
(stdlib) erl_eval.erl:450: :erl_eval.expr/5
(iex) lib/iex/evaluator.ex:250: IEx.Evaluator.handle_eval/5
(iex) lib/iex/evaluator.ex:230: IEx.Evaluator.do_eval/3
(iex) lib/iex/evaluator.ex:208: IEx.Evaluator.eval/3
(iex) lib/iex/evaluator.ex:94: IEx.Evaluator.loop/1
(iex) lib/iex/evaluator.ex:24: IEx.Evaluator.init/4
So I digged a bit into it, and I have to say, that the library you are using is buiggy.
It uses erlangs :public_key.pem_decode/1
, which returns a list, but your library tries to match this list with an ok-tuple.
So you should stop using that library. Perhaps use the erlang modules directly that ex_crtypto
is just a wrapper for?