Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do I get an error with my code in erlang 21 but not in erlang 20?

Tags:

erlang

When I do the following in Erlang 21 I get an error.

inets:start(),
ssl:start(),
httpc:request(post,
             {"https://sandbox.itunes.apple.com/verifyReceipt", [], "application/json", []},
             [], []).

The error is:

=INFO REPORT==== 3-Oct-2018::19:32:47.728491 ===
TLS client: In state hello received SERVER ALERT: Fatal - Handshake Failure

{error,{failed_connect,[{to_address,{"sandbox.itunes.apple.com",443}},
                        {inet,[inet],{tls_alert,"handshake failure"}}]}}

When I do the the same in Erlang 20, it works just fine.

Can someone clue me in on what might be wrong?

like image 501
Xavier Avatar asked Oct 04 '18 01:10

Xavier


Video Answer


1 Answers

Made some research and found that due to OTP 21 Highlights

Security: "unsecure" ciphers removed from defaults in SSL and SSH.

You need to configure SSL manualy (enable ciphers)

EnabledCiphers = ssl:cipher_suites(all, 'tlsv1.2'),
Options = [{ciphers, EnabledCiphers}],

httpc:request(post,{"https://sandbox.itunes.apple.com/verifyReceipt",
[],"application/json", []}, [{ssl,Options}], []).
like image 50
Eugen Dubrovin Avatar answered Oct 03 '22 16:10

Eugen Dubrovin