-
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
Enhance certificate verification process #185
Conversation
library/X509/CertificateUtils.php
Outdated
$db->update('x509_certificate_chain', $set, ['id = ?' => $chainId]); | ||
}; | ||
|
||
foreach ($certs as $cert) { |
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.
I'd like to make this a library function, e.g.
/**
* Yield sets of items from an iterator grouped by a specific criterion gathered from a callback
*
* @param Iterator $iterator
* @param callable $groupBy
*
* @return Generator
*/
function yield_groups(Iterator $iterator, callable $groupBy): Generator
{
if (! $iterator->valid()) {
return;
}
$attribute = $groupBy($iterator->current(), $iterator->key());
$group = [$iterator->current()];
// $group = [$iterator->key() => $iterator->current()];
$iterator->next();
for (; $iterator->valid(); $iterator->next()) {
$a = $groupBy($iterator->current(), $iterator->key());
if ($a !== $attribute) {
yield $attribute => $group;
$group = [];
$attribute = $a;
}
$group[] = $iterator->current();
// $group[$iterator->key()] = $iterator->current();
}
if (! empty($group)) {
yield $attribute => $group;
}
}
What do you think? And @nilmerg what do you think?
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.
When the values to be grouped, i.e. $group[] = $iterator->current()
could also be specified by a callback, it would work. Such a grouping function would also be used for Sla queries in Icinga DB Web.
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.
Sure. Though, why not foreach?
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.
Sure. Though, why not foreach?
We need special handling for the first item in the iterator. With foreach, we would have this code in every iteration.
Please both have a look at Icinga/ipl-stdlib#46.
0ea62fc
to
8386913
Compare
Blocked by |
8386913
to
c505546
Compare
This PR reduces the number of database queries performed per certificate chain to a single query and allocates temp file storage per certificate chain (this makes it possible to free all storage files after each iteration, which should prevent the disk from being crowded when there are a large number of certificate chains to verify).
fixes #175