ViperCoderJay

ViperCoderJay

(UndefinedFunctionError) function :crypto.hmac/3 is undefined or private

I’m failing to render any page, the application takes giving me the following error

[error] #PID<0.1204.0> running ElixirWeb.Endpoint (connection #PID<0.1203.0>, stream id 1) terminated
Server: localhost:8080 (http)
Request: GET /
** (exit) an exception was raised:
    ** (UndefinedFunctionError) function :crypto.hmac/3 is undefined or private
        (crypto 5.0) :crypto.hmac/3
        (plug_crypto 1.2.0) lib/plug/crypto/key_generator.ex:81: Plug.Crypto.KeyGenerator.generate/7
        (plug_crypto 1.2.0) lib/plug/crypto/key_generator.ex:67: Plug.Crypto.KeyGenerator.with_cache/3
        (plug_crypto 1.2.0) lib/plug/crypto/key_generator.ex:51: Plug.Crypto.KeyGenerator.generate/6
        (plug 1.11.0) lib/plug/session/cookie.ex:114: Plug.Session.COOKIE.put/4
        (plug 1.11.0) lib/plug/session.ex:94: anonymous fn/3 in Plug.Session.before_send/2
        (elixir 1.12.0) lib/enum.ex:2356: Enum."-reduce/3-lists^foldl/2-0-"/3
        (plug 1.11.0) lib/plug/conn.ex:1691: Plug.Conn.run_before_send/2
        (plug 1.11.0) lib/plug/conn.ex:407: Plug.Conn.send_resp/1
        (phoenix 1.5.6) lib/phoenix/endpoint/render_errors.ex:78: Phoenix.Endpoint.RenderErrors.instrument_render_and_send/5
        (phoenix 1.5.6) lib/phoenix/endpoint/render_errors.ex:64: Phoenix.Endpoint.RenderErrors.__catch__/5
        (phoenix 1.5.6) lib/phoenix/endpoint/cowboy2_handler.ex:65: Phoenix.Endpoint.Cowboy2Handler.init/4
        (cowboy 2.8.0) ~/elixir/deps/cowboy/src/cowboy_handler.erl:37: :cowboy_handler.execute/2
        (cowboy 2.8.0) ~/elixir/deps/cowboy/src/cowboy_stream_h.erl:300: :cowboy_stream_h.execute/3
        (cowboy 2.8.0) ~/elixir/deps/cowboy/src/cowboy_stream_h.erl:291: :cowboy_stream_h.request_process/3
        (stdlib 3.15) proc_lib.erl:226: :proc_lib.init_p_do_apply/3

Marked As Solved

fuelen

fuelen

Try to update plug_crypto library. It uses :crypto.hmac/3 which was removed in OTP 24.
As you can see on GitHub, newer version of plug_crypto supports OTP 24 plug_crypto/lib/plug/crypto/key_generator.ex at 6ba8fd42a68351459fe6c769ca04aea6022a5cd1 · elixir-plug/plug_crypto · GitHub

17
Post #1

Also Liked

CafeRacer

CafeRacer

In case you are using a pure Elixir implementation without Plug.

:crypto.hmac/{3,4} is deprecated and is removed in Erlang/OTP 24.

:crypto.mac/4 should be instead, but it is available only since Erlang/OTP 22.1.

Both functions yield the same result:

iex(6)> :crypto.mac(:hmac, :sha256, "key", "data") == :crypto.hmac(:sha256, "key", "data")
true
iex(7)> :crypto.mac(:hmac, :sha384, "key", "data") == :crypto.hmac(:sha384, "key", "data")
true
manhtranlinh

manhtranlinh

By this error I have just know now mix there are more interesting options :smiley:
Example: mix deps.update --all

kip

kip

ex_cldr Core Team

:crypto.hmac/3 is not available in OTP 24 (it was deprecated in OTP 23). This is being called from mongodb - which therefore needs updating. And it looks like this commit on September 28th does exactly that.

Since that code appears unreleased you might be able to adjust your mix.exs to be:

def deps do
  ...
  {:mongodb, github: "elixir-mongo/mongodb"},
  ...
end

Last Post!

zookzook

zookzook

You can try out mongodb_driver | Hex which has support for OTP 23 and OTP 24.

Where Next?

Popular in Questions Top

jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New

Other popular topics Top

minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 42716 114
New
AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New

We're in Beta

About us Mission Statement