achedeuzot / ueberauth_auth0

Auth0 OAuth2 strategy for Überauth.
https://hexdocs.pm/ueberauth_auth0
MIT License
71 stars 46 forks source link

Unknown CA error? #159

Closed Pklong closed 3 years ago

Pklong commented 3 years ago

Elixir 1.11.4 (compiled with Erlang/OTP 23)

Attempting to set up auth0 for my phoenix application.

# config.exs
config :ueberauth, Ueberauth,
  providers: [
    auth0: {Ueberauth.Strategy.Auth0, []}
  ]

config :ueberauth, Ueberauth.Strategy.Auth0.OAuth,
  domain: System.get_env("AUTH0_DOMAIN"),
  client_id: System.get_env("AUTH0_CLIENT_ID"),
  client_secret: System.get_env("AUTH0_CLIENT_SECRET")

  #. auth_controller
  defmodule PhotonWeb.AuthController do
  use PhotonWeb, :controller

  plug Ueberauth

  alias Ueberauth.Strategy.Helpers

  def request(conn, _params) do
    callback_url = Helpers.callback_url(conn)
    render(conn, "request.html", callback_url: callback_url)
  end

  def delete(conn, _params) do
    conn
    |> put_flash(:info, "You have been logged out!")
    |> clear_session()
    |> redirect(to: "/")
  end

  def rejected(conn, _params) do
    render(conn, "rejected.html")
  end

  def callback(%{assigns: %{ueberauth_failure: _fails}} = conn, _params) do
    conn
    |> put_flash(:error, "Failed to authenticate.")
    |> redirect(to: "/auth/rejected")
  end

  def callback(%{assigns: %{ueberauth_auth: auth}} = conn, _params) do
    case Photon.Accounts.find_or_create(auth) do
      {:ok, user} ->
        conn
        |> put_flash(:info, "Successfully authenticated.")
        |> put_session(:current_user, user)
        |> configure_session(renew: true)
        |> redirect(to: "/")

      {:error, reason} ->
        conn
        |> put_flash(:error, reason)
        |> redirect(to: "/auth/rejected")
    end
  end
end

Running into the following error on the callback. Any guidance would be appreciated...

** (exit) an exception was raised:
    ** (OAuth2.Error) {:tls_alert, {:unknown_ca, 'TLS client: In state wait_cert_cr at ssl_handshake.erl:1895 generated CLIENT ALERT: Fatal - Unknown CA\n'}}
        (oauth2 2.0.0) lib/oauth2/client.ex:312: OAuth2.Client.get_token!/4
        (ueberauth_auth0 0.8.1) lib/ueberauth/strategy/auth0.ex:134: Ueberauth.Strategy.Auth0.handle_callback!/1
        (ueberauth 0.6.3) lib/ueberauth/strategy.ex:307: Ueberauth.Strategy.run_callback/2
Pklong commented 3 years ago

Resolved by updating Hackney from 1.13 to 1.17.4 🤷