hackeny#

hackney - HTTP client library in Erlang

https://github.com/benoitc/hackney

Use SSL/TLS with self signed certificates#

https://github.com/benoitc/hackney#use-ssltls-with-self-signed-certificates

hackney を自己署名証明書に対して使う場合、 ssl_options を適切に設定する必要がある。 特に以下に注意。

ssl_options overrides all options passed to the ssl module.

また、有効期限2050年を超える証明書は Certificate Expired となる。 理由は、 pubkey_cert.erl の validate_time 関数が呼ぶ time_str_2_gregorian_sec() が以下のように実装されているからである。 引数に {:utcTime, '501110024603Z'} を渡すと1950年として扱われてしまうため。

time_str_2_gregorian_sec({utcTime, [Y1,Y2,M1,M2,D1,D2,H1,H2,M3,M4,S1,S2,Z]}) ->
  case list_to_integer([Y1,Y2]) of
    N when N >= 50 ->
        time_str_2_gregorian_sec({generalTime,
                [$1,$9,Y1,Y2,M1,M2,D1,D2,
                 H1,H2,M3,M4,S1,S2,Z]});
    _ ->
        time_str_2_gregorian_sec({generalTime,
                [$2,$0,Y1,Y2,M1,M2,D1,D2,
                 H1,H2,M3,M4,S1,S2,Z]})
  end;