Skip to content

Commit

Permalink
Convert certificates if necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
jekuaitk committed Jan 23, 2025
1 parent df3ba03 commit dabc589
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/KeyHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,15 @@ public function getCertificates(KeyInterface $key): array {
throw $this->createSslRuntimeException(sprintf('Invalid key type: %s', $type::class), $key);
}

return $this->parseCertificates($key->getKeyValue(), $type->getInputFormat(), $type->getPassphrase(), $key);
// Check whether conversion is needed.
if ($type->getInputFormat() === $type->getOutputFormat()) {
return $this->parseCertificates($key->getKeyValue(), $type->getInputFormat(), $type->getPassphrase(), $key);
}

$preConvertedCertificates = $this->parseCertificates($key->getKeyValue(), $type->getInputFormat(), $type->getPassphrase(), $key);
$convertedAndCombinedCertificate = $this->convertCertificates($preConvertedCertificates, $type->getOutputFormat(), $key);

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

/**
Expand Down

0 comments on commit dabc589

Please sign in to comment.