fwoodruff
I appreciate this question is highly similar to another I asked yesterday. However, while the solution there works on MacOS, on Debian I am getting different errors, and a different set of problems.
First I create a new project with mix new tls_question. I have added :crypto and :ssl to mix.exs like so:
def application do
[
extra_applications: [:logger, :crypto, :ssl]
]
end
I have then generated an SSL certificate with
openssl req -nodes -new -x509 -keyout key.pem -out cert.pem
and moved key.pem and cert.pem into the project folder.
I then have the following minimal program
defmodule TlsQuestion do
def main do
:ssl.start()
{:ok, listen_socket} = :ssl.listen(8000,
[ certs_keys: [%{
:keyfile => "key.pem",
:certfile => "cert.pem",
}],
reuseaddr: true,
])
end
end
TlsQuestion.main()
Calling mix run, I get the error:
== Compilation error in file lib/tls_question.ex ==
** (exit) :badarg
(kernel) inet_tcp.erl:142: :inet_tcp.listen/2
(ssl) tls_socket.erl:51: :tls_socket.listen/3
(ssl) ssl.erl:145: :ssl.listen/2
lib/tls_question.ex:4: TlsQuestion.main/0
Trending in Questions
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app?
Looking for hints regarding:
Addi...
New
Kia ora,
We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
Hi all, I wanted to ask how the community is dealing with post-release steps.
Today we have Ecto migrations, which make sure that the db...
New
Hello,
I have an Elixir backend that implements a custom protocol over TCP. I want to load test the backend and assess the performance o...
New
Other Trending Topics
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #phoenix_html
- #iex
- #graphql
- #ai
- #genstage
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex










Showing Posts 1 to 10- Show Best Posts
- Show All Posts (oldest first)
- Show All Posts (newest first)
al2o3cr
The
badarghere is caused bydo_connectnot finding an address to bind to (the bigwhenclause):https://github.com/erlang/otp/blob/401968245bbd92673512565f8f56305d78e62420/lib/kernel/src/inet_tcp.erl#L118-L144
Based on the
Compilation errorin the message, I believe the issue is theTlsQuestion.main()on the last line - that tries to start the listener when the file is compiled. That’s not needed if you’re launching it withmix run 'TlsQuestion.main()'.fwoodruff
I tried running
mix run 'TlsQuestion.main()'without changing the code. That gives the same error.I then tried removing the line
which gave the error:
I then tried making a similar project.
which gives the error
al2o3cr
Oops, that was a typo - there’s a flag missing. Should be
mix run -e 'TlsQuestion.main()'fwoodruff
That gives me
which seems to the same error with a slightly longer stack trace?
jjcarstens
I don’t believe
reuseaddris a valid listen option (according to gen_tcp — OTP 29.0.2 (kernel 11.0.2))Erlang SSL options can be confusing because they are all effectively included in the specs, but run through a very specific validation when attempting to run
fwoodruff
I’ve taken a look and I’m pretty sure the option is in there. Here is what it’s for.
I have attempted to remove the option anyway to see if anything different happens and the answer is no.
jjcarstens
You’re right. After a closer look, that option should be fine.
I tried the initial code you posted and it worked for me with
mix run -e 'TlsQuestion.main(). I might suggest hardcoding full paths to the cert/key and testing again. Also, what OTP version are you using?:certs_keysis a newer option in OTP 25. I tried this same code with OTP 24 and got the same error you see which makes me believe that thebadargis referencing thecerts_keysoption and your lower OTP version.You could instead just use this as well:
fwoodruff
I’m running OTP 21 on my Raspberry Pi. Is there an alternative way to get SSL working on OTP 21? I’ve rolled my own TLS 1.2 implementation before but that was in another language and I don’t fancy doing it again.
asdf install erlang latestgives me:then CCL seems to peg the CPU to 95% for hours. Attempts to install Java tell me ARMv6 isn’t good enough. It all suggests to me I’m stuck with OTP 21.
jjcarstens
Well, you have a few options:
Do you need multiple certs with
:certs_keys?certfileandkeyfileoption directly which should work with OTP 21If yes, do you need Java? That can be disabled. You would also need to install openSSL on the rpi and specify both of these in
KERL_CONFIGURE_OPTIONS.KERL_CONFIGURE_OPTIONS="--without-javac --with-ssl=/path/to/openssl/install"Are you using the whole raspberry pi OS? Or just to run Erlang/Elixir on it?
fwoodruff
This solves it thank you!!! Cool I’ll try that for installing Java. It might come in handy at some point.
I am currently using the whole Raspberry Pi OS. I can see you work at Nerves and I’ll take a look at it and spread the word!