1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.OTPVersion do
6 @type check_status() :: :ok | :undefined | {:error, String.t()}
8 @spec check!() :: :ok | no_return()
16 !!!OTP VERSION WARNING!!!
17 You are using gun adapter with OTP version #{version}, which doesn't support correct handling of unordered certificates chains.
22 !!!OTP VERSION WARNING!!!
23 To support correct handling of unordered certificates chains - OTP version must be > 22.2.
28 @spec check() :: check_status()
30 # OTP Version https://erlang.org/doc/system_principles/versions.html#otp-version
32 Path.join(:code.root_dir(), "OTP_VERSION"),
33 Path.join([:code.root_dir(), "releases", :erlang.system_info(:otp_release), "OTP_VERSION"])
35 |> get_version_from_files()
39 @spec check([Path.t()]) :: check_status()
42 |> get_version_from_files()
46 defp get_version_from_files([]), do: nil
48 defp get_version_from_files([path | paths]) do
49 if File.exists?(path) do
52 get_version_from_files(paths)
56 defp do_check(nil), do: :undefined
58 defp do_check(version) do
59 version = String.replace(version, ~r/\r|\n|\s/, "")
64 |> Enum.map(&String.to_integer/1)
67 if (major == 22 and minor >= 2) or major > 22 do