Skip to content

Instantly share code, notes, and snippets.

@asv
Created July 31, 2013 07:24
Show Gist options
  • Save asv/6120009 to your computer and use it in GitHub Desktop.
Save asv/6120009 to your computer and use it in GitHub Desktop.
Extract SSL certificate from the hackney request
#! /usr/bin/escript
-include_lib("hackney/include/hackney.hrl").
-include_lib("public_key/include/public_key.hrl").
main([]) ->
ok = hackney:start(),
{ok, 200, _, C} = hackney:request(get, <<"https://friendpaste.com">>, [], <<>>, []),
{ok, Cert} = ssl:peercert(C#client.socket),
DecodedCert = public_key:pkix_decode_cert(Cert, plain),
io:format("Certificate: ~p~n", [DecodedCert]),
ok.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment