'How do I do an HTTPS request with Erlang?

I tried the inets library but it times out. I don't think it supports HTTPS. I am trying to use ibrowse, but it isn't working.



Solution 1:[1]

This is what worked for me:

application:start(crypto),
application:start(public_key),
application:start(ssl),
application:start(inets).

httpc:request(head, {"https://example.com", []}, [{ssl,[{verify,0}]}], []).

Solution 2:[2]

For me this worked for a get request (with peer verification enabled) in Yaws 2.1.0 on Erlang/OTP 24:

application:start(inets).
application:start(crypto).
application:start(asn1).
application:start(public_key).
application:start(ssl).

httpc:request(get, {"https://example.com", []}, 
    [{ssl, [{verify, verify_peer}, {cacertfile,"/path/to/cacertfile.crt"}]}], []).

Else there will be the warning: "Authenticity is not established by certificate path validation"

For more options see: https://www.erlang.org/doc/man/httpc.html#request-4

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Sebastian Hölzl