#1298: Handle only private key info from PEM #1299
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Task-Url: #1298
Pull Request Checklist
Helpful things
Fixes
Fixes #1298
Purpose
It appears some PEM's only contain a private key and not a pair containing the private and public key as is the case with LetsEncrypt so added an additional test to check if just the private key was provided. Also updated BouncyCastle version to v1.61 and unified the logic to first retrieve the private key info from all of the various PEM formats and then retrieve the private key from the private key info. I tested this locally with a self certified certificate that is processed as a PEMKeyPair and LetsEncrypt certificate that is processed as a PrivateKeyInfo. Finally, now an exception is thrown if there is an unrecognised PEM format for retrieving the private key.