概述

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

问题

httpc ssl options verify: 0 导致failed_connect

现象

Erlang/OTP 23 [erts-11.1] [source] [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] [source] [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] [source] [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] [source] [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] [source] [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中找到


enjolras1205
77 声望9 粉丝