Testing Plug with client certificates

Hello,

I have a Plug that tries to force the client to send their SSL certificate when the request is done (Mutual TLS auth. https://tools.ietf.org/html/rfc8705). Under the hood, it the check looks like this:

case Plug.Conn.get_peer_data(conn)[:ssl_cert] do
      nil ->
        {:error...}

Now I am trying to run tests using the following approach:
conn(:post, path, json_body) |> MyPlug.call(@opts)

However, it’s not clear how to set a certificate on conn.

Plug.Test.put_peer_data/2 looks like it will do what you want.