Skip to content

Commit ca96b75

Browse files
authored
Merge pull request #5 from itk-dev/feature/convert-certificates-into-output-format
Convert certificates when necessary
2 parents df3ba03 + 620489d commit ca96b75

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

CHANGELOG.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
* [PR-5](https://github.com/OS2web/os2web_key/pull/5)
11+
Convert certificates when necessary.
1012
* [PR-4](https://github.com/OS2web/os2web_key/pull/4)
11-
Added HashiCorp Vault key provider
13+
Added HashiCorp Vault key provider.
1214
* [PR-2](https://github.com/OS2web/os2web_key/pull/2)
13-
Updated documentation
15+
Updated documentation.
1416
* [PR-1](https://github.com/OS2web/os2web_key/pull/1)
15-
Added OS2Web key module
17+
Added OS2Web key module.
1618

1719
[Unreleased]: https://github.com/rimi-itk/os2web_key

src/KeyHelper.php

+8-1
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+
$parsedCertificates = $this->parseCertificates($key->getKeyValue(), $type->getInputFormat(), $type->getPassphrase(), $key);
47+
$convertedCertificates = $this->convertCertificates($parsedCertificates, $type->getOutputFormat(), $key);
4248

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

4552
/**

0 commit comments

Comments
 (0)