Skip to content

Commit b67a4c9

Browse files
committed
Add missing behavior docs & rename DistinguishedEncodingRules
1 parent 9c2a33d commit b67a4c9

File tree

6 files changed

+25
-11
lines changed

6 files changed

+25
-11
lines changed

application/clicommands/CheckCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public function hostAction()
116116
$targets->filter(Filter::equal('hostname', $hostname));
117117
}
118118
if ($this->params->has('port')) {
119-
$targets->filter(Filter::equal('port', (int) $this->params->get('port')));
119+
$targets->filter(Filter::equal('port', $this->params->get('port')));
120120
}
121121

122122
$allowSelfSigned = (bool) $this->params->get('allow-self-signed', false);

library/X509/Job.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ protected function processChain($target, $chain)
455455
);
456456
$targetId = $this->db->lastInsertId();
457457
} else {
458-
$targetId = (int) $row->id;
458+
$targetId = $row->id;
459459
}
460460

461461
$chainUptodate = false;
@@ -474,7 +474,7 @@ protected function processChain($target, $chain)
474474
->getSelectBase()
475475
->where(new Expression(
476476
'certificate_link.certificate_chain_id = %d',
477-
[(int) $lastChain->id]
477+
[$lastChain->id]
478478
))
479479
->orderBy('certificate_link.order');
480480

@@ -523,13 +523,16 @@ protected function processChain($target, $chain)
523523
$lastCertInfo[] = $index;
524524
}
525525

526-
$rootCa = X509Certificate::on($this->db);
527-
$rootCa
526+
// There might be chains that do not include the self-signed top-level Ca,
527+
// so we need to include it manually here, as we need to display the full
528+
// chain in the UI.
529+
$rootCa = X509Certificate::on($this->db)
528530
->columns(['id'])
529-
->filter(Filter::equal('issuer_hash', $lastCertInfo[1]))
530-
->filter(Filter::equal('trusted', true));
531+
->filter(Filter::equal('subject_hash', $lastCertInfo[1]))
532+
->filter(Filter::equal('self_signed', true))
533+
->first();
531534

532-
if (($rootCa = $rootCa->first()) && $rootCa->id !== $lastCertInfo[0]) {
535+
if ($rootCa && $rootCa->id !== $lastCertInfo[0]) {
533536
$this->db->update(
534537
'x509_certificate_chain',
535538
['length' => count($chain) + 1],

library/X509/Model/Behavior/DistinguishedEncodingRules.php renamed to library/X509/Model/Behavior/DERBase64.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44

55
use ipl\Orm\Contract\PropertyBehavior;
66

7-
class DistinguishedEncodingRules extends PropertyBehavior
7+
/**
8+
* Support automatically transformation of DER-encoded certificates to PEM and vice versa.
9+
*/
10+
class DERBase64 extends PropertyBehavior
811
{
912
public function fromDb($value, $key, $_)
1013
{

library/X509/Model/Behavior/ExpressionInjector.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
use ipl\Orm\Query;
88
use ipl\Stdlib\Filter;
99

10+
/**
11+
* Support expression columns (which don't really exist in the database, but rather
12+
* resulted e.g. from a `case..when` expression), being used as filter columns
13+
*/
1014
class ExpressionInjector implements RewriteFilterBehavior, QueryAwareBehavior
1115
{
1216
/** @var array */

library/X509/Model/Behavior/Ip.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
use ipl\Orm\Contract\PropertyBehavior;
66

7+
/**
8+
* Support automatically transformation of human-readable IP addresses into their respective packed
9+
* binary representation and vice versa.
10+
*/
711
class Ip extends PropertyBehavior
812
{
913
public function fromDb($value, $key, $_)

library/X509/Model/X509Certificate.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Icinga\Module\X509\Model;
44

5-
use Icinga\Module\X509\Model\Behavior\DistinguishedEncodingRules;
5+
use Icinga\Module\X509\Model\Behavior\DERBase64;
66
use Icinga\Module\X509\Model\Behavior\ExpressionInjector;
77
use ipl\Orm\Behavior\Binary;
88
use ipl\Orm\Behavior\BoolCast;
@@ -120,7 +120,7 @@ public function createBehaviors(Behaviors $behaviors)
120120
'certificate'
121121
]));
122122

123-
$behaviors->add(new DistinguishedEncodingRules(['certificate']));
123+
$behaviors->add(new DERBase64(['certificate']));
124124

125125
$behaviors->add(new BoolCast([
126126
'ca',

0 commit comments

Comments
 (0)