Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not working from within escript #35

Closed
MathiasWedeken opened this issue Aug 31, 2021 · 2 comments
Closed

not working from within escript #35

MathiasWedeken opened this issue Aug 31, 2021 · 2 comments

Comments

@MathiasWedeken
Copy link

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
Copy link
Author

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
Copy link
Member

ericmj commented Aug 31, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants