-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mutual TLS / client certificate #412
Comments
I've pushed docs update to main, if passing :cacertfile is not enough, please lmk! |
Thanks for the quick response! As fas as I know, CA certificates are used to validate that server certificate is emitted by a trusted authority, works as authenticating the server on the client side. However, client certificates works the opposite: they are used to authenticate the client against the server, and the server is the one that have a CA that matches the client certificate. it is like having a two-way certificate communication (here some documentation). In other libraries (docs), it can be done passing |
Right, replace: options = [ssl: [certfile: "certs/client.crt"]]
{:ok, response} = HTTPoison.post(url, [], options) with options = [connect_options: [transport_opts: [cacertfile: "certs.pem"]]]
Req.get!(url, options) and you should be good to go. Transport options are documented here: https://hexdocs.pm/mint/Mint.HTTP.html#connect/4-transport-options |
Hi! I'm trying to make the requests as you mention but I'm getting the following error:
I don't know if I've tried to convert that
with same result. |
is that .pfx working with httpoison that you mentioned prior? |
It's NOT with In |
I think the reason is that CA certificate is used to validate the server certificate, and the client certificate is a different thing: it is sent to the server. |
what happens when in httpoison you additionally set You can disable server verification with |
Responses with HTTPoison:
|
Thanks for following up. The best way to figure this out is to reproduce with Mint so we remove extra layers like Finch and Req. With Mint this should work:
My recommendation is to first of all take this snippet and make sure it works (eg without cert, to a regular host), modify it in a way that should work and when it doesn’t, ask people on ElixirForum etc, the question will have more visibility and broader community could help. Sorry I couldn’t be more helpful. |
I've just made Req works with this params: I've tried with this options just because is the name in HTTPoison and... it worked 😂 |
Oh, wow, good to know. |
Hello,
Thanks a lot for building Req, it's really a life saver 🚀
I'm trying to use Req to communicate with an external service that uses Mutual TLS (client certificates) as authentication.
Is it possible to use Req for this? I have been looking for documentation on Mint but no luck so far. I found a thread in ElixirForum talking about an option which is no longer in the docs or in the source code, so I'm not sure it will work anymore.
Is there any known way of using client certificates to do requests with Req?
Thanks
The text was updated successfully, but these errors were encountered: