How to get a peer certificate in cowboy_http_handler

My question for today is: is there an official way to get information about ssl socket juice (more precisely, certificate exact match) in cowboy_http_handler Handler:handle(Req, State)?

Of course, I can scrape Reqtuple (peer-to-peer status is the second field today) with erlang:element/2, but it is not reliable for the future and just does not look right.

Thanks in advance!

+4
source share
1 answer

There is an export call:

cowboy_req:get(socket, Req)

It returns a socket or almost everything else in the object Req, currently:

bindings
body_state
buffer
connection
headers
host
host_info
meta
method
multipart
onresponse
path
path_info
peer
pid
port
qs
resp_body
resp_compress
resp_headers
resp_state
socket
transport
version

, , , , , unit test , , , - /, -. , .

+4

Source: https://habr.com/ru/post/1620368/


All Articles