Reputation: 1682
I know this is very basic, but it's driving me up a wall:
peercert is defined as:
peercert(Socket) -> {ok, Cert} | {error, Reason}
Types
Socket = sslsocket()
Cert = binary()
The peer certificate is returned as a DER-encoded binary. The certificate can be decoded with public_key:pkix_decode_cert/2.
Ok, great. sslsocket is defined as -record(sslsocket, {fd = nil, pid = nil})
So I run :
New = #sslsocket{pid = Pid},
io:fwrite("~n~npeercert~p~n~n", [ssl:peercert(New)]).
But I get an error that
no function clause matching ssl:peercert({sslsocket,<0.1277.0>,undefined})
So I run it with Pid as an argument and get a similar error:
no function clause matching ssl:peercert(<0.1277.0>)
I'm totally stumped here. I had it working before, the function says it takes these as arguments...
Thank you for your help in advance!
Upvotes: 0
Views: 58
Reputation: 513
sslsocket()
type is not a record called sslsocket
, otherwise it would be written as #sslsocket{}
. It's a "black box type" (its real type is an implementation detail), but you can obtain it from function ssl:connect()
.
Upvotes: 1