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 #2

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

Where Next?

Popular in Questions Top

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
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
LegitStack
I’m trying to make a websocket server in Phoenix or raw Elixir. I heard about gun, I think I could use cowboy, but since I’m not that sma...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New

Other popular topics Top

senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
Nvim
Anybody knows a comprehensive comparison of Django and Phoenix, thanks for the help. Where are they similar? Where do they differ the m...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
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
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 53690 245
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
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New

We're in Beta

About us Mission Statement