-
Notifications
You must be signed in to change notification settings - Fork 24
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
Report expired status in CLI but not module interface #232
Comments
Hi @sdaru, thanks for reporting! Can you please provide a screenshot of that chain's detail from Icinga Web? Perhaps the issuer of your |
That CA it's internal and we renew and import into it and it's all valid i just double check before start first scan. Kind Regards. |
If you don't want to expose CA details publicly, you can blur all the sensible information. I just want to see the expiration date of all certificates within that chain. |
Blur isn't very destructive. Just put a block over it. |
No news guys ? |
I have a similar problem.
|
Are you guys all using MySQL/MariaDB? Actually, there shouldn't be any discrepancy when using PostgreSQL, but the former ones seem to do some unexpected things. The x509 check commands determines certificate from/to date in a given chain using a min/max aggregates... icingaweb2-module-x509/application/clicommands/CheckCommand.php Lines 92 to 105 in 8425ede
... which seem to just work fine with PostgreSQL: postgres=# SELECT MAX(GREATEST(3185943150, NULL)) AS max;
max
------------
3185943150
(1 row)
postgres=# SELECT MIN(LEAST(3185943150, NULL)) AS min;
min
------------
3185943150
(1 row) MySQL/MariaDB: MariaDB [x509]> SELECT MAX(GREATEST(3185943150, NULL)) AS max;
+------+
| max |
+------+
| NULL |
+------+
1 row in set (0.000 sec)
MariaDB [x509]> SELECT MIN(LEAST(3185943150, NULL)) AS min;
+------+
| min |
+------+
| NULL |
+------+
1 row in set (0.000 sec) As you can see from the output above, MariaDB returns a null timestamp if the certificate is not part of a chain, which is the case in your scenario. When calculating the from - to timestamp of the certificate from @slalomsk8er's screenshot above, the output is the same as in the UI. root@506429f94d6f:/# date -d '2070-12-16 08:12:30' +%s
3185943150 root@506429f94d6f:/# php -a
Interactive shell
php > $to = new DateTime();
php > $to->setTimestamp(3185943150);
php > $now = new DateTime();
php > $reminder = $to->getTimestamp() - $now->getTimestamp();
php > var_dump(($reminder - $reminder % 86400) / 86400);
int(17044) |
Worse, it's a MariaDB Galera Cluster. |
After rechecking the generated query, I've to correct myself with this statement, in fact it also affects PostgreSQL. The subqueries for In case you need a fix right now, you can use this patch, which should solve the problem. diff --git a/application/clicommands/CheckCommand.php b/application/clicommands/CheckCommand.php
index 0c369d9..cd6e363 100644
--- a/application/clicommands/CheckCommand.php
+++ b/application/clicommands/CheckCommand.php
@@ -108,8 +108,12 @@ class CheckCommand extends Command
list($validToSelect, $_) = $validTo->dump();
$targets
->withColumns([
- 'valid_from' => new Expression($validFromSelect),
- 'valid_to' => new Expression($validToSelect)
+ 'valid_from' => new Expression(
+ sprintf('COALESCE((%s), target_chain_certificate.valid_from)', $validFromSelect)
+ ),
+ 'valid_to' => new Expression(
+ sprintf('COALESCE((%s), target_chain_certificate.valid_to)', $validToSelect)
+ )
])
->getSelectBase()
->where(new Expression('target_chain_link.order = 0'));
That's actually by design and works as it should! Like I said before, the check command determines the greatest |
@yhabteab Thank you, I will try the patch immediately. I disagree, as in the first picture shown, the chain is valid and on the second pictures it shows also old certificates and to me it looks like somehow the check picks them up in contrast to the web interface, that shows a valid chain as does Chrome. |
Well, initially I didn't notice that the certificate subject is the same for all the certificates listed in the UI, but it seems like you have some outdated data in your database.
Can you please try to cleanup your database as described in here before opening a new issue. |
Not sure if a clean up is a good idea before we understand the problem. My suspicion is that, because of the self signing, it doesn't replace old ones but chains them and the module interface and the CLI handle them differently. Your patch removed a bunch but I still have at least one similar case.
|
Actually, I was able to reproduce this after some time 🙈. $ icingacli x509 check --host 'self-signed-one'
CRITICAL - self-signed-one: self-signed certificate; self-signed-one expires in 59 days|'self-signed-one'=5179266s;1296000:;518400:;0;5181933 MariaDB [x509]> SELECT COUNT(*) FROM x509_certificate where subject = 'self-signed-one';
+----------+
| COUNT(*) |
+----------+
| 2 |
+----------+
1 row in set (0.000 sec) With #240: $ icingacli x509 check --host 'self-signed-one'
CRITICAL - self-signed-one: self-signed certificate; self-signed-one expires in 99 days|'self-signed-one'=8635468s;2160000:;864000:;0;8635598 Edit: Though as I said before, a cleanup command would have fixed that too, since you're removing unused certificates with the same subject name that would otherwise cause conflicts. |
@yhabteab I still get the diff between cli and web gui for:
also |
Nope, that's the expected result! Your |
@yhabteab problem is, those self signed certs aren't the issuer certificates, still show up after Maybe I should try to schedule a call with you via the Linuxfabrik? |
Can you please provide me the output of the following query, we can then coordinate a call if that does not help me identify the cause. (Please start MariaDB with the SELECT *
FROM x509_certificate
INNER JOIN x509.x509_certificate_chain_link link on x509_certificate.id = link.certificate_id
INNER JOIN x509.x509_certificate_chain chain on link.certificate_chain_id = chain.id
INNER JOIN x509.x509_target x509t on chain.target_id = x509t.id
WHERE chain.id = CHAIN_ID_OF_YOUR_CORRUPT_CERTIFICATE; |
@yhabteab done, were to send it privately? |
The certificate chain you provided me is totally messed up, and I don't even know why it is considered to be a valid chain, as the actual issuer of that certificate is not part of that chain. Also, can you upload the output of I have also tried to recreate your situation by providing a number of meaningless certificates in my nginx cert file, and was able to kind of reproduce it. The first certificate expires in about But I suppose the check command should only consider certificates with $ icingacli x509 check --host 'self-signed-one'
OK - self-signed-one expires in 399 days|'self-signed-one'=34558908s;8640000:;3456000:;0;34560000 |
I know, the chain is a complete mess. |
That's the confusing part, the orphaned certificates are still part of the new chain with the new certificate, which makes me think the web server is doing some fancy stuff and that's the reason I'm asking for this:
Usually, when a host receives a new certificate, a new certificate chain is also created, and when you subsequently run the cleanup command, the old chain of that host and its relationships gets removed as it is no longer used by a target host. But your chain is still used by a host target. |
It looks like the the useless line |
Describe the bug
Certificates show has expired on icingacli/icingaweb but not on module interface
To Reproduce
I think it was working fine before i update that package (before i had version 1.0.0). But now after drop and recreate db and use last version of module, Even if the certification is showing correct information en Web interface (Certificate chain is valid. / in XX days), the cli and icingaweb (since it uses the cli), shows error:
icingacli x509 check host --host 'myhost.domain.org'
CRITICAL - myhost.domain.org has expired since 240 days|'myhost.domain.org''=0s;1209600:;604800:;0;360353
From webpage of tht host that host work well.
i have same issue with different host (via cli)
Expected behavior
Show current status and not trigger warning/error status.
Your Environment
Include as many relevant details about the environment you experienced the problem in
Can someone help me ?
Originally posted by @sdaru in #211 (comment)
The text was updated successfully, but these errors were encountered: