[release/6.0] Fix OpenSSL 3 reporting an OutOfMemoryException for missing private key #63955
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.
Backport of #63804 to release/6.0.
Customer Impact
Reported in #63624 by Red Hat. Customers moving to Linux distributions that come with OpenSSL 3, the next major version of OpenSSL, will experience incorrect exceptions when attempting to perform private key operations using only a public key.
Prior to this change, we reported an
OutOfMemoryException
on OpenSSL 3 when using a public-only key for operations that required a private key. This adjusts the exception throwing logic to report aCryptographicException
as we are with OpenSSL 1.x.Testing
This was uncovered by existing tests when run against OpenSSL 3.0. The tests were manually run against a Linux distribution that includes OpenSSL 3.0, in this case Fedora 36. With the changes, the tests began to pass again.
Risk
Low. Existing test infrastructure ensures we remain working with OpenSSL 1.x. The change is simply to react to OpenSSL's error conditions differently in an isolated location.