Skip to content
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

process certificate chains presented by the client #9795

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

sircubbi
Copy link

@sircubbi sircubbi commented Jun 20, 2023

Similar to #8859 this patch works around #7719 by allowing the intermediate certificate presented by the icinga2-agent.

To make this work the icinga2-master only holds to root-ca in its local ca.crt, while the icinga2-agent has the intermediate-cert in its local ca.crt (or the intermediate together with the root in the ca.crt / or the intermediate in the cert.pem - doesn't matter).

Edit (@Al2Klimov)

closes #9026

Copy link
Member

@Al2Klimov Al2Klimov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or the intermediate in the cert.pem

So with this PR -in contrast to master- #8859 (comment) (haven’t tested yet) should just work?

lib/cli/pkiverifycommand.cpp Outdated Show resolved Hide resolved
lib/remote/apilistener.cpp Outdated Show resolved Hide resolved
lib/base/tlsutility.hpp Outdated Show resolved Hide resolved
@julianbrost
Copy link
Contributor

At first glance, this looks more like the change I was expecting for certificate changes. 👍

@sircubbi
Copy link
Author

or the intermediate in the cert.pem

So with this PR -in contrast to master- #8859 (comment) (haven’t tested yet) should just work?

That is correct. The intermediate can either go into the cert.pem or into the ca.pem (on the agent-side) as well. OpenSSL internally picks up all the chain-elements and send them over, so no change is actually needed on the agent-side. Only the master needs to pickup the (untrusted) chain from the wire and tries to validate the whole set against its local root-ca-cert.

lib/base/tlsutility.hpp Show resolved Hide resolved
lib/base/tlsutility.cpp Show resolved Hide resolved
lib/base/tlsstream.hpp Show resolved Hide resolved
lib/base/tlsstream.cpp Show resolved Hide resolved
lib/remote/jsonrpcconnection-pki.cpp Outdated Show resolved Hide resolved
lib/remote/jsonrpcconnection-pki.cpp Show resolved Hide resolved
@Al2Klimov Al2Klimov self-requested a review June 21, 2023 14:50
Copy link
Member

@Al2Klimov Al2Klimov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait...

lib/base/tlsstream.cpp Show resolved Hide resolved
lib/base/tlsutility.cpp Show resolved Hide resolved
lib/remote/jsonrpcconnection-pki.cpp Show resolved Hide resolved
Copy link
Member

@Al2Klimov Al2Klimov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Context: #9798

@@ -69,7 +69,7 @@ String SHA256(const String& s);
String RandomString(int length);
String BinaryToHex(const unsigned char* data, size_t length);

bool VerifyCertificate(const std::shared_ptr<X509>& caCertificate, const std::shared_ptr<X509>& certificate, const String& crlFile);
bool VerifyCertificate(const std::shared_ptr<X509>& caCertificate, const std::shared_ptr<X509>& certificate, const String& crlFile, STACK_OF(X509) *chain = nullptr);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Maybe I've asked too early for a default value here.) What are the now implicit-nullptr usages and (why) should they (not) also get some chains?

Al2Klimov
Al2Klimov previously approved these changes Jun 22, 2023
Copy link
Member

@Al2Klimov Al2Klimov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But, to be honest, one strange error message less is already an improvement. (But not for 2.14.)

@julianbrost Do you agree?

@julianbrost
Copy link
Contributor

Hold on a second, do I understand this correctly: You're saying (also taking information from #9798 into account here) that node certificates signed by an intermediate CA work perfectly fine apart from a log message that doesn't limit the functionality ("Received certificate request for CN ... not signed by our CA:")?

So the claim made by #9026 (put that renewal stuff in an if and things work) was indeed correct?

And in contrast, this PR would fix it by making the renewal logic aware of the chain which contains the intermediates required for verification?

@Al2Klimov
Copy link
Member

Yes. IMAO we don’t even need #9026 on every node, instead we could check the root CA name in code or so. But I prefer PRs like this one.

@julianbrost
Copy link
Contributor

I didn't want to revive #9026 but my intuition about that PR was "how could this possibly make intermediate certificates work", but if it wasn't even that broken, it makes a bit more sense now.

@sircubbi
Copy link
Author

Just to give an update: I am still in the process of reading through your comments (also in #9798). However because of vacation in the next week it will be a little bit delayed, hope that is ok.

@Al2Klimov Al2Klimov added this to the 2.15.0 milestone Aug 22, 2023
@Al2Klimov Al2Klimov added the area/distributed Distributed monitoring (master, satellites, clients) label Oct 23, 2023
Similar to Icinga#8859 this patch works
around Icinga#7719 by allowing the
intermediate certificate presented by the icinga2-agent.

To make this work the icinga2-master only holds to root-ca in its local
ca.crt, while the icinga2-agent has the intermediate-cert in its local
ca.crt (or the intermediate together with the root in the ca.crt / or
the intermediate in the cert.pem - doesn't matter).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/distributed Distributed monitoring (master, satellites, clients) cla/signed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants