[erlang-questions] SSL peer certificate verification - RabbitMQ

Bloom, Adam Adam.Bloom@REDACTED
Thu Jun 8 00:35:56 CEST 2017

Hi Ingela,

Ok, that’s what I was starting to think the right approach is as well. Do you have an example of implementing this function? I’m just a rabbitmq user, not an Erlang developer. But sounds like I’ll get to learn a thing or two about a new language ☺


From: Ingela Andin <ingela.andin@REDACTED>
Date: Wednesday, June 7, 2017 at 2:07 PM
To: Adam Bloom <Adam.Bloom@REDACTED>
Cc: "erlang-questions@REDACTED" <erlang-questions@REDACTED>
Subject: Re: [erlang-questions] SSL peer certificate verification - RabbitMQ


You should use the partial chain option. The fun shall return the intermediate cert present in the inputed Chain that it wants to trust. The depth option specifies the maximum intermediate CAs there
can be in the chain, that is not what you want.

"{partial_chain, fun(Chain::[DerCert]) -> {trusted_ca, DerCert} | unknown_ca }

Claim an intermediate CA in the chain as trusted. TLS then performs public_key:pkix_path_validation/3<https://urldefense.proofpoint.com/v2/url?u=http-3A__erlang.org_doc_man_public-5Fkey.html-23pkix-5Fpath-5Fvalidation-2D3&d=DwMFaQ&c=jcv3orpCsv7C4ly8-ubDob57ycZ4jvhoYZNDBA06fPk&r=pVjMG-Ic_gFf_XuCeIHdvT-JeR4iyCqatl3BZUquOU8&m=RdLD9uLBXT7i2qO5z3I7haERmcOZ37ixd02093FC6ws&s=pBqdi5eawOebOQIbO_8E5Ea7d81OVPcSFqU3GR1cq1g&e=> with the selected CA as trusted anchor and the rest of the chain."

Regards Ingela Erlang/OTP team

2017-06-05 20:27 GMT+02:00 Bloom, Adam <Adam.Bloom@REDACTED<mailto:Adam.Bloom@REDACTED>>:

Hoping that one of you knows some secrets you can impart in me to get SSL peer verification working from RabbitMQ. I’ve been digging through the source code of the underlying Erlang SSL library to no avail. In particular, I’m struggling to understand the depth setting. According to the docs (http://erlang.org/doc/man/ssl.html<https://urldefense.proofpoint.com/v2/url?u=http-3A__erlang.org_doc_man_ssl.html&d=DwMFaQ&c=jcv3orpCsv7C4ly8-ubDob57ycZ4jvhoYZNDBA06fPk&r=pVjMG-Ic_gFf_XuCeIHdvT-JeR4iyCqatl3BZUquOU8&m=RdLD9uLBXT7i2qO5z3I7haERmcOZ37ixd02093FC6ws&s=SvDIXk5--5EFPmkoBywSdMm7VbEsIbeBC_8xn1vXigc&e=>):

{depth, integer()}
Maximum number of non-self-issued intermediate certificates that can follow the peer certificate in a valid certification path. So, if depth is 0 the PEER must be signed by the trusted ROOT-CA directly; if 1 the path can be PEER, CA, ROOT-CA; if 2 the path can be PEER, CA, CA, ROOT-CA, and so on. The default value is 1.

I have two certificates (client and server) signed by the same intermediate CA. I would like to restrict rabbitmq to only accept connections from this (and potentially one more) intermediate CA. My initial thought was to set depth to 0 and place the intermediate ca (followed by the root ca) in the CA cert file. If I do this, the client is unable to connect and the server logs the following error:
SSL: certify: ssl_handshake.erl:1627:Fatal error: handshake failure - {bad_cert,max_path_length_reached}.

If I change depth to 1, the connection works. Rabbitmq also allows a cert signed by another intermediate ca (same root) to connect, which is what I’d like to prevent. This follows from the ssl man page though.

Can someone please advise me on the proper use of the “depth” setting in the Erlang ssl library such that only certificates signed by the trusted intermediate are able to connect? Do I need to remove the root CA from the CA cert file and explore partial_chain handlers?

Here are my current ssl_options settings from rabbitmq:
{ssl_options, [
            {cacertfile, "/etc/rabbitmq/certs/cacert.pem"},
            {certfile, "/etc/rabbitmq/certs/cert.pem"},
            {keyfile, "/etc/rabbitmq/certs/key.pem"},
            {verify, verify_peer},
           {depth, 1},
            {fail_if_no_peer_cert, true},
            {versions, ['tlsv1.2']}



erlang-questions mailing list

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20170607/7d262d46/attachment.htm>

More information about the erlang-questions mailing list