[Backport] Fix parsing of PBES2 encrypted PKCS#8 keys#79352
Merged
tvernum merged 9 commits intoelastic:7.16from Oct 25, 2021
Merged
[Backport] Fix parsing of PBES2 encrypted PKCS#8 keys#79352tvernum merged 9 commits intoelastic:7.16from
tvernum merged 9 commits intoelastic:7.16from
Conversation
This commit adds support for decrypting PKCS#8 encoded private keys that have been encrypted using a PBES2 based scheme (AES only). Unfortunately `java.crypto.EncryptedPrivateKeyInfo` doesn't make this easy as the underlying encryption algorithm is hidden within the `AlgorithmParameters`, and can only be extracted by calling `toString()` on the parameters object. See: https://datatracker.ietf.org/doc/html/rfc8018#appendix-A.4 See: AlgorithmParameters#toString() See: com.sun.crypto.provider.PBES2Parameters#toString() Backport of: elastic#78904
Collaborator
|
Pinging @elastic/es-security (Team:Security) |
Contributor
Author
|
@jkakavas As part of the backport, I added special case code for JDK8 because the JDK enhancements we rely on were backported to 8 |
Contributor
Author
Turns out it is supported on Oracle JDK8, but not OpenJDK8 |
Contributor
Author
|
@elasticmachine update branch |
jkakavas
approved these changes
Oct 23, 2021
Contributor
jkakavas
left a comment
There was a problem hiding this comment.
LGTM, sorry I missed the original ping for the review. I added a comment about the oracle vs openjdk 8 case but I'm fine as it is now.
| } | ||
| if (JavaVersion.current().compareTo(JavaVersion.parse("11.0.0")) < 0) { | ||
| // PBES2 appears to be supported on Oracle 8, but not OpenJDK8 | ||
| // We don't both clarifying that here because it is supported on the bundled JDK, and that's what people should use |
Contributor
There was a problem hiding this comment.
both -> bother ( in case you need to make another commit for another reason)
libs/ssl-config/src/main/java/org/elasticsearch/common/ssl/PemUtils.java
Outdated
Show resolved
Hide resolved
tvernum
added a commit
to tvernum/elasticsearch
that referenced
this pull request
Oct 26, 2021
This commit adds support for decrypting PKCS#8 encoded private keys that have been encrypted using a PBES2 based scheme (AES only). Unfortunately `java.crypto.EncryptedPrivateKeyInfo` doesn't make this easy as the underlying encryption algorithm is hidden within the `AlgorithmParameters`, and can only be extracted by calling `toString()` on the parameters object. See: https://datatracker.ietf.org/doc/html/rfc8018#appendix-A.4 See: AlgorithmParameters#toString() See: com.sun.crypto.provider.PBES2Parameters#toString() This support is conditional on the underlying support in the JDK, which is absent from OpenJDK 8, but should work on all other supported JDKs. Backport of: elastic#78904 Backport of: elastic#79352
elasticsearchmachine
pushed a commit
that referenced
this pull request
Oct 26, 2021
This commit adds support for decrypting PKCS#8 encoded private keys that have been encrypted using a PBES2 based scheme (AES only). Unfortunately `java.crypto.EncryptedPrivateKeyInfo` doesn't make this easy as the underlying encryption algorithm is hidden within the `AlgorithmParameters`, and can only be extracted by calling `toString()` on the parameters object. See: https://datatracker.ietf.org/doc/html/rfc8018#appendix-A.4 See: AlgorithmParameters#toString() See: com.sun.crypto.provider.PBES2Parameters#toString() This support is conditional on the underlying support in the JDK, which is absent from OpenJDK 8, but should work on all other supported JDKs. Backport of: #78904 Backport of: #79352
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This commit adds support for decrypting PKCS#8 encoded private keys
that have been encrypted using a PBES2 based scheme (AES only).
Unfortunately
java.crypto.EncryptedPrivateKeyInfodoesn't make thiseasy as the underlying encryption algorithm is hidden within the
AlgorithmParameters, and can only be extracted by callingtoString()on the parameters object.See: https://datatracker.ietf.org/doc/html/rfc8018#appendix-A.4
See: AlgorithmParameters#toString()
See: com.sun.crypto.provider.PBES2Parameters#toString()
Backport of: #78904