Skip to content

Commit dabc589

Browse files
committed
Convert certificates if necessary
1 parent df3ba03 commit dabc589

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/KeyHelper.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,15 @@ public function getCertificates(KeyInterface $key): array {
3838
throw $this->createSslRuntimeException(sprintf('Invalid key type: %s', $type::class), $key);
3939
}
4040

41-
return $this->parseCertificates($key->getKeyValue(), $type->getInputFormat(), $type->getPassphrase(), $key);
41+
// Check whether conversion is needed.
42+
if ($type->getInputFormat() === $type->getOutputFormat()) {
43+
return $this->parseCertificates($key->getKeyValue(), $type->getInputFormat(), $type->getPassphrase(), $key);
44+
}
45+
46+
$preConvertedCertificates = $this->parseCertificates($key->getKeyValue(), $type->getInputFormat(), $type->getPassphrase(), $key);
47+
$convertedAndCombinedCertificate = $this->convertCertificates($preConvertedCertificates, $type->getOutputFormat(), $key);
4248

49+
return $this->parseCertificates($convertedAndCombinedCertificate, $type->getOutputFormat(), $type->getPassphrase(), $key);
4350
}
4451

4552
/**

0 commit comments

Comments
 (0)