Skip to content

Instantly share code, notes, and snippets.

@Mutjake
Created July 15, 2016 15:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mutjake/14a65bc127a7ff73974347aa2ad67f02 to your computer and use it in GitHub Desktop.
Save Mutjake/14a65bc127a7ff73974347aa2ad67f02 to your computer and use it in GitHub Desktop.
#!/usr/bin/env escript
%% -*- erlang -*-
%% trytls (https://github.com/ouspg/trytls) stub for erlang
%% Uncomment the following line if needed. Hard to say if compiling is worthwhile here.
%% -mode(compile).
main([Url, Port]) ->
start_deps(),
Result = httpc:request("https://" ++ Url ++ ":" ++ Port),
check(Result);
main([Url, Port, CaFile]) ->
start_deps(),
Result = httpc:request(head, {"https://" ++ Url ++ ":" ++ Port, []}, [{ssl,[{cacertfile, CaFile}]}], []),
check(Result);
main(_) ->
usage().
usage() ->
io:format("usage: run <domain> <port> [ca_file]~n"),
io:format("Will do request as: https://<domain>:<port>~n").
start_deps() ->
inets:start(),
ssl:start().
check({ok, _}) ->
io:format("VERIFY SUCCESS~n");
check({error, _}) ->
io:format("VERIFY FAILURE~n");
check(_) ->
io:format("VERIFY FAILURE~n").
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment