Fl4m3Ph03n1x
Background
We are making a proof of concept to use a postgres DB with Elixir. To achieve this we are using Postgrex.
Issue
The problem here is we need to connect to the DB using a certificate instead of a username and password. Unfortunately the documentation only has 1 example where one connects via username and password.
{:ok, pid} = Postgrex.start_link(hostname: "localhost", username: "postgres", password: "postgres", database: "postgres")
Research
I have read the documentation and I found that I can use the ssl and ssl_opts parameters when connecting to the DB: Postgrex — Postgrex v0.22.2
However, the documentation tells me to loo for the ssl docs, but no link is given.
It is the first time I am dealing with this kind of information in Elixir, I have no idea on how to proceed from here on.
Questions
- How do I connect to my postgres DB using a certificate and Postgrex?
- What are these
ssl_optsdocuments the documentation refers to? How do they translate to Elixir code?
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 5- Show Best Posts
- Show All Posts (oldest first)
- Show All Posts (newest first)
hauleth
It tells you to look into
sslmodule of Erlang standard library. To be exact you should look attls_option/0. In the end it is keyword list with values specified in these type specs.Fl4m3Ph03n1x
Would it be something like this?
hauleth
As documentation states that
:certfileneed to bestring()which is Erlang’s string, in Elixir known as charlist you need to do this like that:voltone
It depends what you’re trying to achieve by using TLS. If you just want to authenticate with a client certificate while obscuring data from passive observers, then just a
:certfileoption may work, assuming this one file contains the client certificate, any intermediate certificates needed, and the private key. If the private key is stored in a separate file you’d have to pass a:keyfileoption as well.If you want to strongly authenticate the server, to prevent active (MitM) attacks, you’re going to have to pass in a few more options, starting with
verify: :verify_peer, the server’s hostname (using the:server_name_indicationoption is easiest) and the trusted CA certificates (using the:cacertfileoption, which may interfere with selection of the client certificate’s intermediate CA certs).Fl4m3Ph03n1x
This is really valuable information. I felt quite lost reading through all of those examples, it’s always good to have some extra directions.
We’re not completely sure of our implementation, but if we have additional questions we’ll be sure to post them in the forum.
As a followup from this discussion I made a PR to improve the docs:
https://github.com/elixir-ecto/postgrex/pull/486
As a newcomer, I truly believe I needed more directions and the docs were at fault. This is my approach to improving them (the simplest approach I could think of, though I am still not convinced it’s enough).
Feel free to drop in with any suggestions on how to improve.