samfrench
We are using Cowboy with a HTTPS listener and would like to do mTLS. We have a similar setup using nginx in another application and specify a certificate file (ssl_client_certificate) which allows us to verify client certificates. We also specify another certificate file (ssl_certificate) to allow clients to verify the server.
Is it possible in Cowboy to specify these two certificates? We can have one for the clients to verify the server but not too sure on how we can verify client certificates. I only see one “certfile” property in the configuration.
Our configuration is similar to this:
[
certfile: "/path/to/cert.crt",
keyfile: "/path/to/key.key",
cacertfile: "/path/to/cacert.crt",
verify: :verify_peer,
depth: 3
]
We would like to be able to verify client certificates while allowing the server to present a different certificate to clients for them to trust the server.
There might be documentation for how we can do this but I have not seen anything specifically for this setup or comparable to nginx. Any help with how we can achieve this is appreciated.
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #ai
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #elixirconf-eu
- #metaprogramming
- #hex










Showing Posts 1 to 7- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
moogle19
You should take a look at ssl — OTP 29.0.2 (ssl 11.7.2)
When you specify
cacertfile/cacertson the server-side, these are normally used to verify the client certificate.LostKobrakai
That’s the documentation for ranch, which is the library cowboy uses underneight.
voltone
Keep in mind that the
cacertsandcacertfileoptions serve two roles when doing mTLS: they are used to specify the trust store used when verifying the other party’s certificate, and also to look up any intermediates that may need to be included in the ‘chain’ that is sent for the local party’s certificate.So on a server, the CA certs would have to include the server certificate’s intermediates and the trusted CA that issued the client certs. And on the client, CA certs should include the usual CA trust store (or the specific one that issued the server’s cert, if you want to pin it that way) and any intermediates that should be sent with the client certificate.
In recent OTP versions you can, as an alternative approach, set
certsto a list containing the local endpoint’s certificate and intermediates, and in that casecacertswould only have to contain the trust store.samfrench
Thank you for this. I think I have got further as don’t get an invalid security warning now - due to the certificate configuration not being correct.
I am currently getting an unknown CA but think this is due to the self signed certificates.
I have included all CAs in the “cacerts” property in a list reading them in.
I assume it will be the certificates I am using and need to add others into the list. I was wondering if there was anything else due to it being self signed but it seems unlikely.
samfrench
I found using “partial_chain” and having a function to return a trusted CA solves this. I think I have got there now. Thank you for the help.
tj0
Can you post your solution for future generations?
edit: relevant xkcd - xkcd: Wisdom of the Ancients
samfrench
The solution that worked is here: