not working from within escript
MathiasWedeken opened this issue · 2 comments
MathiasWedeken commented
This issue pops up when sending an HTTPS request via Finch.
It seems as though CAStoe is not compiled into the binary built via escript.build.
** (ArgumentError) unknown application: :castore
(elixir 1.12.0) lib/application.ex:880: Application.app_dir/1
(elixir 1.12.0) lib/application.ex:907: Application.app_dir/2
(mint 1.3.0) lib/mint/core/transport/ssl.ex:572: Mint.Core.Transport.SSL.add_cacerts/1
(mint 1.3.0) lib/mint/core/transport/ssl.ex:442: Mint.Core.Transport.SSL.add_verify_opts/2
(mint 1.3.0) lib/mint/core/transport/ssl.ex:432: Mint.Core.Transport.SSL.ssl_opts/2
(mint 1.3.0) lib/mint/core/transport/ssl.ex:328: Mint.Core.Transport.SSL.connect/4
(mint 1.3.0) lib/mint/http1.ex:114: Mint.HTTP1.connect/4
(finch 0.8.1) lib/finch/http1/conn.ex:45: Finch.Conn.connect/1
(finch 0.8.1) lib/finch/http1/pool.ex:45: anonymous fn/8 in Finch.HTTP1.Pool.request/5
(nimble_pool 0.2.4) lib/nimble_pool.ex:266: NimblePool.checkout!/4
(finch 0.8.1) lib/finch/http1/pool.ex:39: Finch.HTTP1.Pool.request/5
(finch 0.8.1) lib/finch.ex:261: Finch.request/3
(property_finances_import 0.3.0) lib/property_finances_import/soap_client.ex:106: SOAP.get_soap_response/3
(elixir 1.12.0) lib/task/supervised.ex:90: Task.Supervised.invoke_mfa/2
(elixir 1.12.0) lib/task/supervised.ex:35: Task.Supervised.reply/5
(stdlib 3.15) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
MathiasWedeken commented
For anyone running into the same issue, workaround for now is:
-copy the file "priv/cacerts.pem" from this app to your root-application priv
-configure Finch like so:
children = [
{Finch,
name: MyFinch,
pools: %{
default: [
conn_opts: [
transport_opts: [
cacertfile: "priv/cacerts.pem"
]
]
]
}}
]
ericmj commented
Unfortunately it is not possible to easily access application directories (including priv/) from inside escripts since they are inside a zip file.
See the NOTE at the end of the task documentation: https://hexdocs.pm/mix/Mix.Tasks.Escript.Build.html.