Skip to content

Instantly share code, notes, and snippets.

@choestelus
Created January 17, 2020 10:28
Show Gist options
  • Save choestelus/d94be5138441b4ffbf172101fefd503e to your computer and use it in GitHub Desktop.
Save choestelus/d94be5138441b4ffbf172101fefd503e to your computer and use it in GitHub Desktop.
defmodule PingPgTls.DBConnection do
def test_connect do
opts = [
hostname: "localhost",
port: 5432,
username: "postgres",
password: "postgres",
database: "postgres",
ssl: true,
ssl_opts: [
cacertfile: "cert/pg_ca.crt",
keyfile: "cert/pg_client.key",
certfile: "cert/pg_client.crt",
verify: :verify_peer,
version: [:"tlsv1.2", :"tlsv1.3"],
server_name_indication: :disable,
fallback: false
]
]
{:ok, pid} = Postgrex.start_link(opts)
IO.inspect(pid)
Postgrex.query!(pid, ~s(SELECT 1+1), []) |> IO.inspect()
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment