-
Notifications
You must be signed in to change notification settings - Fork 584
API: Update the ssl context after each accepting incoming connection #8515
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
API: Update the ssl context after each accepting incoming connection #8515
Conversation
232413e
to
26b3fec
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Call GetCrlPath() only once at all
- Call Utility::GetFileCreationTime() at most once per accept.
- If you just start Icinga 2 with an empty CRL configured, don't touch the CRL after start and establish your first connection, will Icinga 2 update the context?
So, if I don't configure the CRL path in |
Only once? Where? |
2099d56
to
3e49386
Compare
Well here! |
... and here: icinga2/lib/remote/apilistener.cpp Line 179 in 9b6326c
Do you consider your additional update neccessary? |
No, but I can't prevent it either! |
You're writing this new code. Of course you can prevent it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You've just addressed incoming connections here. What about outgoing ones?
If the incoming connection has been checked and successfully validated at the master, why do I have to add an additional check for the outgoing one. We only need to update the master and not the ones connected to it, because this has no effect at all if the master doesn't notice anything. |
Also address outgoing connections. |
68771e1
to
6dac79b
Compare
I don't see any actual changes. |
Master and agent disabled and I have revoked the certificates from the agent. After that I started both and master noticed that the crt is revoked. Agent turned off and undo crt revokation, agent started again, crt validation was successful and no error messages for revoked crts. |
Fine. Undo the commit message change. |
6dac79b
to
2b6f484
Compare
Do you know why the Github actions fail? |
Figure it out. |
dddc7fb
to
72a9768
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Write a test protocol.
Testprotocol: Before: See #8501 After: Revoke the certificate while the master and the agent are stopped and then start them both. Master Log: [2020-12-07 12:30:11 +0100] information/ApiListener: New client connection for identity 'ha-cluster' from [::1]:49781 (certificate validation failed: code 23: certificate revoked)
[2020-12-07 12:30:11 +0100] information/JsonRpcConnection: Received certificate request for CN 'ha-cluster' signed by our CA.
[2020-12-07 12:30:11 +0100] information/JsonRpcConnection: The certificate for CN 'ha-cluster' is valid and uptodate. Skipping automated renewal. And now update the [2020-12-07 12:35:21 +0100] warning/JsonRpcConnection: API client disconnected for identity 'ha-cluster'
[2020-12-07 12:35:31 +0100] information/ApiListener: New client connection for identity 'ha-cluster' from [::1]:49823
[2020-12-07 12:35:31 +0100] information/ApiListener: Sending config updates for endpoint 'ha-cluster' in zone 'ha-cluster'. |
Can you please test what happens in the following scenarios:
|
[2020-12-07 12:56:28 +0100] critical/SSL: Error loading crl file '~/var/lib/icinga2/ca/ha-master.crl': 33558530, "error:02001002:system library:fopen:No such file or directory"
[2020-12-07 12:56:28 +0100] critical/config: Error: Cannot add certificate revocation list to SSL context for crl path: '~/var/lib/icinga2/ca/ha-master.crl'.
[2020-12-07 13:01:15 +0100] critical/SSL: Error loading crl file '~/var/lib/icinga2/ca/ha-master.crl': 218529960, "error:0D0680A8:asn1 encoding routines:asn1_check_tlen:wrong tag"
[2020-12-07 13:01:15 +0100] critical/config: Error: Cannot add certificate revocation list to SSL context for crl path: '~/var/lib/icinga2/ca/ha-master.crl'. |
What is the general behavior in this case? Will Icinga terminate? If not, will if accept new connections? If it does, are these verified against the old CRL? |
So, if you enter CRL path, which does not exist at all, or the CRL file is invalid Icinga2 will terminate while compiling the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use git rebase
to reorder your commits. Currently the first commit already uses GetFileCreationTime
which is only introduced in the second one.
72a9768
to
2f0edf0
Compare
2f0edf0
to
d27f533
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So as this generates a whole new context, this implicitly also reloads certificates and private keys, but only when a CRL exists and is changed. I think this is fine, as nothing bad should happen there unless someone manually messes around with stuff.
resolves #8501