Skip to content

Issues running in an environment without OS level certificates. #141

@thiagogsr

Description

@thiagogsr

** For future users that encounter issues **

In gun version 2.1.0 an attempt is made to load certificates from the OS. Even if you disable verification this will be done.

This appears to trigger something similar to: erlang/otp#7303

To work around this issue there are a few couple.

  1. Add certificates to the OS.
  2. Specify the cacerts option. (for instance your own list of certificates, an empty list, or using certifi.)

Describe the bug
The library cannot connect to LaunchDarkly on 3.5.0.

To reproduce
Install LaunchDarkly 3.5.0

Expected behavior
It should connect.

Logs

:gen_statem #PID<0.6585.0> terminating
** (MatchError) no match of right hand side value: :undefined
    (public_key 1.15.1.1) pubkey_os_cacerts.erl:39: :pubkey_os_cacerts.get/0
    (gun 2.1.0) /build/deps/gun/src/gun.erl:1129: :gun.ensure_tls_opts/3
    (gun 2.1.0) /build/deps/gun/src/gun.erl:1103: :gun.initial_tls_handshake/3
    (stdlib 5.2.3) gen_statem.erl:1395: :gen_statem.loop_state_callback/11
    (stdlib 5.2.3) proc_lib.erl:241: :proc_lib.init_p_do_apply/3
Queue: [internal: {:retries, 0, #Port<0.24>}]
Postponed: []
State: :initial_tls_handshake
Data: {:state, #PID<0.6584.0>, {:up, #Reference<0.4255606911.3075735553.131477>}, ~c"stream.launchdarkly.com", 443, "https", ~c"stream.launchdarkly.com", 443, [], %{protocols: [:http], retry: 0, transport: :tls, connect_timeout: 2000, retry_timeout: 1, tcp_opts: [], tls_opts: [verify: :verify_none]}, :undefined, :undefined, :gun_tls, true, {:ssl, :ssl_closed, :ssl_error}, :undefined, :undefined, :undefined, :gun_default_event_h, :undefined}
Callback mode: :state_functions, state_enter: false

SDK version
3.5.0

Language version, developer tools
ERLANG_VERSION=26.2.5.1
ELIXIR_VERSION=1.17.1

OS/platform
DEBIAN_VERSION=bookworm-20240701

Additional context
It fails with both:

:ldclient.start_instance(api_key, instance_name)

and

:ldclient.start_instance(api_key, instance_name, %{http_options: %{tls_options: [{:verify, :verify_none}]}})

Dependencies versions

:certifi, "2.13.0"
:eredis, "1.7.1"
:jsx, "3.1.0"
:lru, "2.4.0"
:shotgun, "1.1.0"
:uuid_erl, "2.0.7"
:verl, "1.0.1"
:yamerl, "0.10.0"

UPDATE:
I've tried with:

:ldclient.start_instance(api_key, instance_name, %{http_options: %{tls_options: :ldclient_config.tls_basic_options()}})

and it connected, however, the variation function does not work due to:

** (exit) exited in: :gen_server.call(instance_name, {:add_event, %{data: %{default: "default", value: "default", version: :null, debug: false, key: "key-name", variation: :null, prereq_of: :null, trackEvents: :null, debugEventsUntilDate: :null, include_reason: false, eval_reason: {:error, :exception}}, timestamp: 1731943495975, type: :feature_request, context: %{key: "my-key", kind: "my-kind"}}, :my-app, %{}})
    ** (EXIT) no process: the process is not alive or there's no process currently associated with the given name, possibly because its application isn't started
    (stdlib 5.2.3) gen_server.erl:404: :gen_server.call/2
    (stdlib 5.2.3) lists.erl:1686: :lists.foreach_1/2
    (ldclient 3.5.0) /build/deps/ldclient/src/ldclient.erl:147: :ldclient.variation/4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions