Skip to content

Commit 025e0e5

Browse files
authored
Merge pull request #79 from Spomky-Labs/temp-bbef23
Merge up 1.4.1 to 1.5.X
2 parents 77198ae + f0e9a54 commit 025e0e5

5 files changed

Lines changed: 16 additions & 6 deletions

File tree

src/X509/CertificationPath/PathValidation/PathValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ private function setPublicKeyState(ValidatorState $state, Certificate $cert): Va
222222
if ($pk_info->algorithmIdentifier()->oid() !==
223223
$state->workingPublicKeyAlgorithm()
224224
->oid()) {
225-
$state = $state->withWorkingPublicKeyParameters(null);
225+
$state = $state->withWorkingPublicKeyParameters();
226226
}
227227
}
228228
// assign working_public_key_algorithm

src/X509/CertificationPath/PathValidation/ValidatorState.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public static function initialize(PathValidationConfig $config, Certificate $tru
141141
$state->_workingPublicKeyParameters = self::getAlgorithmParameters(
142142
$state->_workingPublicKey->algorithmIdentifier()
143143
);
144-
$state->_workingIssuerName = $tbsCert->issuer();
144+
$state->_workingIssuerName = $tbsCert->subject();
145145
$state->_maxPathLength = $config->maxLength();
146146
return $state;
147147
}

src/X509/GeneralName/IPv4Address.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ public static function fromOctets(string $octets): self
3939

4040
protected function octets(): string
4141
{
42-
$bytes = array_map('intval', explode('.', $this->ip));
42+
$bytes = array_map(intval(...), explode('.', $this->ip));
4343
if (isset($this->mask)) {
44-
$bytes = array_merge($bytes, array_map('intval', explode('.', $this->mask)));
44+
$bytes = array_merge($bytes, array_map(intval(...), explode('.', $this->mask)));
4545
}
4646
return pack('C*', ...$bytes);
4747
}

src/X509/GeneralName/IPv6Address.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ protected static function wordsToIPv6String(array $words): string
5151

5252
protected function octets(): string
5353
{
54-
$words = array_map('hexdec', explode(':', $this->ip));
54+
$words = array_map(hexdec(...), explode(':', $this->ip));
5555
if (isset($this->mask)) {
56-
$words = array_merge($words, array_map('hexdec', explode(':', $this->mask)));
56+
$words = array_merge($words, array_map(hexdec(...), explode(':', $this->mask)));
5757
}
5858
return pack('n*', ...$words);
5959
}

tests/X509/Unit/CertificationPath/CertificationPathValidationTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,14 @@ public function explicitTrustAnchor()
9494
$validator = PathValidator::create(Crypto::getDefault(), $config, ...self::$_path->certificates());
9595
static::assertInstanceOf(PathValidationResult::class, $validator->validate());
9696
}
97+
98+
#[Test]
99+
public function explicitTrustAnchorWithIntermediateCA()
100+
{
101+
$trustAnchor = self::$_path->certificates()[1];
102+
$certs = [self::$_path->certificates()[2]];
103+
$config = PathValidationConfig::defaultConfig()->withTrustAnchor($trustAnchor);
104+
$validator = PathValidator::create(Crypto::getDefault(), $config, ...$certs);
105+
static::assertInstanceOf(PathValidationResult::class, $validator->validate());
106+
}
97107
}

0 commit comments

Comments
 (0)