How to set the SSL options when connecting to Heroku in Phoenix framework?

138 Views Asked by At

I recently upgraded Phoenix to the newest version(1.7.7) and Ecto was also upgraded to 3.10.3. Before upgrading, when connecting to Heroku pg, i just set SSL: true and the connection is OK:

config :abc, abc.Repo,
  url: System.get_env("DATABASE_URL"),
  pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10"),
  ssl: true

After upgrading, it failed with the following messages:

[error] Postgrex.Protocol (#PID<0.2449.0>) failed to connect: ** (DBConnection.ConnectionError) ssl connect: Options (or their values) can not be combined: [{verify,verify_peer},
                                                {cacerts,undefined}] - {:options, :incompatible, [verify: :verify_peer, cacerts: :undefined]}

It seemed more options were needed now. There are a lot options and i can't find some examples about how to set them. By the way, Heroku pg mandated the SSL option set, so i can't remove it. Anyone one runs into same problem?

1

There are 1 best solutions below

2
tomwang1013 On

Solution found here:

https://elixirforum.com/t/how-to-set-ssl-options-correctly-when-connecting-to-heroku-postgres-db/59426/2

config :abc, abc.Repo,
  [...]
  ssl_opts: [verify: :verify_none]