Created
July 15, 2016 15:12
-
-
Save Mutjake/14a65bc127a7ff73974347aa2ad67f02 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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