Fix transport_opts

This commit is contained in:
José Valim 2024-01-25 22:13:50 +01:00
parent 883c0f39ec
commit 365cbe7101

View file

@ -21,15 +21,16 @@ defmodule Livebook.Teams.WebSocket do
uri = URI.parse(Livebook.Config.teams_url()) uri = URI.parse(Livebook.Config.teams_url())
{http_scheme, ws_scheme} = parse_scheme(uri) {http_scheme, ws_scheme} = parse_scheme(uri)
state = %{status: nil, headers: [], body: []} state = %{status: nil, headers: [], body: []}
opts = [protocols: [:http1]]
opts = transport_opts =
if http_scheme == :https do if http_scheme == :https do
put_in(opts[:transport_opts][:cacerts], :public_key.cacerts_get()) [cacerts: :public_key.cacerts_get()]
else else
opts []
end end
opts = [protocols: [:http1], transport_opts: transport_opts]
with {:ok, conn} <- Mint.HTTP.connect(http_scheme, uri.host, uri.port, opts), with {:ok, conn} <- Mint.HTTP.connect(http_scheme, uri.host, uri.port, opts),
{:ok, conn, ref} <- Mint.WebSocket.upgrade(ws_scheme, conn, @ws_path, headers) do {:ok, conn, ref} <- Mint.WebSocket.upgrade(ws_scheme, conn, @ws_path, headers) do
receive_upgrade(conn, ref, state) receive_upgrade(conn, ref, state)