关于erlang:从erlang-otp21-升级-otp23-遇到的坑

45次阅读

共计 1721 个字符,预计需要花费 5 分钟才能阅读完成。

概述

最近将 erlang 从 otp21.3.8.17 降级至最新的 otp23.1. 遇到了两个编译不告警, 但版本前后语义不统一, 且在 changelist 中未提及的问题. 在此做个记录.

问题

httpc ssl options verify: 0 导致 failed_connect

景象

Erlang/OTP 23 [erts-11.1]  [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]

Interactive Elixir (1.10.4) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> :httpc.request(:get, {'https://www.baidu.com/', []}, [ssl: [verify: 0]], [])
{:error,
 {:failed_connect,
  [{:to_address, {'www.baidu.com', 443}},
    {:inet, [:inet], {:options, {:verify, 0}}}
  ]}}

定位

发现错误是 ssl 抛出的.

Erlang/OTP 23 [erts-11.1]  [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]

Interactive Elixir (1.10.4) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> :ssl.handle_options([verify: 0], :client)                             
** (throw) {:error, {:options, {:verify, 0}}}
    (ssl 10.1) ssl.erl:2738: :ssl.handle_verify_option/2
    (ssl 10.1) ssl.erl:1644: :ssl.process_options/3
    (ssl 10.1) ssl.erl:1598: :ssl.handle_options/3

ssl-9.2.3.5 无问题.

Erlang/OTP 21 [erts-10.3.5.13]  [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]

Interactive Elixir (1.7.3) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> :ssl.handle_options([verify: 0], :client) 
{:ok,
 {:config,

在 ssl-10.1 的 release node 中未提到废除 verify: 0 的应用

crypt.stream_init 从值语义变为了援用语义

景象

Erlang/OTP 23 [erts-11.1]  [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]

Interactive Elixir (1.10.4) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> :crypto.stream_init(:rc4, "a")
{:rc4, {#Reference<0.1758837082.2328756225.106374>, :flg_undefined}}
Erlang/OTP 21 [erts-10.3.5.13]  [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]

Interactive Elixir (1.7.3) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> :crypto.stream_init(:rc4, "a")
{:rc4,
 <<0, 0, 0, 0, 0, 0, 0, 0, 170, 0, 0, 0, 17, 0, 0, 0, 79, 0, 0, 0, 138, 0, 0, 0,
   225, 0, 0, 0, 85, 0, 0, 0, 57, 0, 0, 0, 113, 0, 0, 0, 223, 0, 0, 0, 54, 0, 0,
   0, ...>>}

同样无奈在 crypto-4.8 的 release-note 中找到

正文完
 0